From 9e9ac7ce3c8f61702adc3ad63ed4e83d6b5b14b8 Mon Sep 17 00:00:00 2001 From: Intel A80486DX2-66 Date: Sun, 24 Nov 2024 12:14:42 +0300 Subject: [PATCH] corrupter.c: allocate correct amount of heap memory --- src/corrupter.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/corrupter.c b/src/corrupter.c index 64cb960..551c508 100644 --- a/src/corrupter.c +++ b/src/corrupter.c @@ -132,8 +132,10 @@ Corrupter_Result corrupt_file(Corrupter_Param* param) { rewind(file); + size_t file_size = end - start; + // allocate memory for the file content - byte* buffer = malloc(end); + byte* buffer = malloc(file_size * sizeof(byte)); if (buffer == NULL) { PERROR_MACRO("malloc"); @@ -156,7 +158,7 @@ Corrupter_Result corrupt_file(Corrupter_Param* param) { } // output data to result - result.file_size = end - start; + result.file_size = file_size; // initialize the PRNG mt_seed(param->seed);