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);