mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-14 18:48:13 -07:00
fix, resource leaks
This commit is contained in:
parent
8dd56a9004
commit
9a2a5496c0
1 changed files with 9 additions and 5 deletions
|
@ -91,8 +91,10 @@ static int zlib_compress(FILE *infile[], uint8_t num_infiles, FILE *outfile, boo
|
|||
} while (!all_feof(infile, num_infiles));
|
||||
|
||||
uint32_t buffer_size = FPGA_RING_BUFFER_BYTES;
|
||||
|
||||
if (num_infiles == 1)
|
||||
buffer_size = 1024*1024; //1M for now
|
||||
|
||||
uint32_t outsize_max = LZ4_compressBound(buffer_size);
|
||||
|
||||
char *outbuf = calloc(outsize_max, sizeof(char));
|
||||
|
@ -145,7 +147,7 @@ static int zlib_compress(FILE *infile[], uint8_t num_infiles, FILE *outfile, boo
|
|||
|
||||
typedef struct lz4_stream_s {
|
||||
LZ4_streamDecode_t* lz4StreamDecode;
|
||||
char * next_in;
|
||||
char* next_in;
|
||||
int avail_in;
|
||||
} lz4_stream;
|
||||
|
||||
|
@ -158,10 +160,11 @@ static int zlib_decompress(FILE *infile, FILE *outfile) {
|
|||
long infile_size = ftell(infile);
|
||||
fseek(infile, 0L, SEEK_SET);
|
||||
|
||||
char * inbuf = calloc(infile_size, sizeof(char));
|
||||
char* inbuf = calloc(infile_size, sizeof(char));
|
||||
size_t num_read = fread(inbuf, sizeof(char), infile_size, infile);
|
||||
|
||||
if (num_read != infile_size) {
|
||||
free(inbuf);
|
||||
return (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
@ -188,6 +191,7 @@ static int zlib_decompress(FILE *infile, FILE *outfile) {
|
|||
printf("uncompressed %li input bytes to %i output bytes\n", infile_size, total_size);
|
||||
fclose(outfile);
|
||||
fclose(infile);
|
||||
free(inbuf);
|
||||
return (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
|
@ -280,7 +284,7 @@ static int FpgaGatherVersion(FILE *infile, char *infile_name, char *dst, int len
|
|||
strncat(dst, " on ", len - strlen(dst) - 1);
|
||||
for (uint16_t i = 0; i < fpga_info_len; i++) {
|
||||
char c = (char)fgetc(infile);
|
||||
if (i < sizeof(tempstr)) {
|
||||
if (i < sizeof(tempstr)) {
|
||||
if (c == '/') c = '-';
|
||||
if (c == ' ') c = '0';
|
||||
tempstr[i] = c;
|
||||
|
@ -314,8 +318,8 @@ static void print_version_info_preamble(FILE *outfile, int num_infiles) {
|
|||
fprintf(outfile, "//\n");
|
||||
fprintf(outfile, "// This file is generated by fpga_compress. Don't edit!\n");
|
||||
fprintf(outfile, "//-----------------------------------------------------------------------------\n");
|
||||
fprintf(outfile, "\n");
|
||||
fprintf(outfile, "\n");
|
||||
fprintf(outfile, "// slurdge, 2020\n");
|
||||
fprintf(outfile, "\n\n");
|
||||
fprintf(outfile, "const int g_fpga_bitstream_num = %d;\n", num_infiles);
|
||||
fprintf(outfile, "const char *const g_fpga_version_information[%d] = {\n", num_infiles);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue