fix: mem leaks.

This commit is contained in:
iceman1001 2019-02-21 15:34:31 +01:00
commit 91d6836a47
7 changed files with 22 additions and 14 deletions

View file

@ -266,14 +266,20 @@ static void init_bitflip_bitarrays(void)
continue;
} else {
fseek(statesfile, 0, SEEK_END);
uint32_t filesize = (uint32_t)ftell(statesfile);
int fsize = ftell(statesfile);
if ( fsize == -1 ){
PrintAndLogEx(WARNING, "File read error with %s. Aborting...\n", state_file_name);
fclose(statesfile);
exit(5);
}
uint32_t filesize = (uint32_t)fsize;
rewind(statesfile);
uint8_t input_buffer[filesize];
size_t bytesread = fread(input_buffer, 1, filesize, statesfile);
if (bytesread != filesize) {
PrintAndLogEx(WARNING, "File read error with %s. Aborting...\n", state_file_name);
fclose(statesfile);
inflateEnd(&compressed_stream);
//inflateEnd(&compressed_stream);
exit(5);
}
fclose(statesfile);