mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-22 06:13:51 -07:00
remove some redundant code and fixed CID# 416023 with resource leak
This commit is contained in:
parent
3397198127
commit
24938e3ed5
1 changed files with 16 additions and 28 deletions
|
@ -301,16 +301,19 @@ static void init_bitflip_bitarrays(void) {
|
||||||
free(path);
|
free(path);
|
||||||
if (statesfile == NULL) {
|
if (statesfile == NULL) {
|
||||||
continue;
|
continue;
|
||||||
} else if (open_uncompressed) {
|
}
|
||||||
fseek(statesfile, 0, SEEK_END);
|
|
||||||
int fsize = ftell(statesfile);
|
fseek(statesfile, 0, SEEK_END);
|
||||||
if (fsize == -1) {
|
int fsize = ftell(statesfile);
|
||||||
PrintAndLogEx(ERR, "File read error with %s. Aborting...\n", state_file_name);
|
if (fsize == -1) {
|
||||||
fclose(statesfile);
|
PrintAndLogEx(ERR, "File read error with %s. Aborting...\n", state_file_name);
|
||||||
exit(5);
|
fclose(statesfile);
|
||||||
}
|
exit(5);
|
||||||
uint32_t filesize = (uint32_t)fsize;
|
}
|
||||||
rewind(statesfile);
|
uint32_t filesize = (uint32_t)fsize;
|
||||||
|
rewind(statesfile);
|
||||||
|
|
||||||
|
if (open_uncompressed) {
|
||||||
|
|
||||||
uint32_t count = 0;
|
uint32_t count = 0;
|
||||||
size_t bytesread = fread(&count, 1, sizeof(count), statesfile);
|
size_t bytesread = fread(&count, 1, sizeof(count), statesfile);
|
||||||
|
@ -347,18 +350,12 @@ static void init_bitflip_bitarrays(void) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
fclose(statesfile);
|
||||||
nraw++;
|
nraw++;
|
||||||
|
continue;
|
||||||
|
|
||||||
} else if (open_lz4compressed) {
|
} else if (open_lz4compressed) {
|
||||||
|
|
||||||
fseek(statesfile, 0, SEEK_END);
|
|
||||||
int fsize = ftell(statesfile);
|
|
||||||
if (fsize == -1) {
|
|
||||||
PrintAndLogEx(ERR, "File read error with %s (1). Aborting...\n", state_file_name);
|
|
||||||
fclose(statesfile);
|
|
||||||
exit(5);
|
|
||||||
}
|
|
||||||
uint32_t filesize = (uint32_t)fsize;
|
|
||||||
rewind(statesfile);
|
|
||||||
char *compressed_data = calloc(filesize, sizeof(uint8_t));
|
char *compressed_data = calloc(filesize, sizeof(uint8_t));
|
||||||
if (compressed_data == NULL) {
|
if (compressed_data == NULL) {
|
||||||
PrintAndLogEx(ERR, "Out of memory error in init_bitflip_statelists(). Aborting...\n");
|
PrintAndLogEx(ERR, "Out of memory error in init_bitflip_statelists(). Aborting...\n");
|
||||||
|
@ -436,15 +433,6 @@ static void init_bitflip_bitarrays(void) {
|
||||||
continue;
|
continue;
|
||||||
} else if (open_bz2compressed) {
|
} else if (open_bz2compressed) {
|
||||||
|
|
||||||
fseek(statesfile, 0, SEEK_END);
|
|
||||||
int fsize = ftell(statesfile);
|
|
||||||
if (fsize == -1) {
|
|
||||||
PrintAndLogEx(ERR, "File read error with %s. Aborting...\n", state_file_name);
|
|
||||||
fclose(statesfile);
|
|
||||||
exit(5);
|
|
||||||
}
|
|
||||||
uint32_t filesize = (uint32_t)fsize;
|
|
||||||
rewind(statesfile);
|
|
||||||
char input_buffer[filesize];
|
char input_buffer[filesize];
|
||||||
size_t bytesread = fread(input_buffer, 1, filesize, statesfile);
|
size_t bytesread = fread(input_buffer, 1, filesize, statesfile);
|
||||||
if (bytesread != filesize) {
|
if (bytesread != filesize) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue