From bb51675a94b6ced86aeb5d1b3ffd98c144e55774 Mon Sep 17 00:00:00 2001 From: Dorian Zedler Date: Wed, 20 Jul 2022 13:45:00 +0200 Subject: [PATCH] Fix: valgrind warnings --- Implementierung/src/io.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Implementierung/src/io.c b/Implementierung/src/io.c index 857a996..e0720a9 100644 --- a/Implementierung/src/io.c +++ b/Implementierung/src/io.c @@ -35,12 +35,13 @@ uint8_t* read_file(const char* path, size_t* size) { struct sysinfo info; int r = sysinfo(&info); - if (r != 0 || info.freeram < (unsigned long)statOfFile.st_size * 2) { + if (r != 0 || info.freeram < (unsigned long)(statOfFile.st_blksize * + statOfFile.st_blocks * 2)) { errno = ENOMEM; return NULL; } - uint8_t* data = malloc(statOfFile.st_size); + uint8_t* data = malloc(statOfFile.st_blksize * statOfFile.st_blocks); if (data == NULL) { fclose(f); return NULL;