mirror of
https://github.com/facebook/zstd.git
synced 2025-11-09 00:11:14 -05:00
Merge pull request #2067 from bimbashrestha/res-leak
[bug] adding fclose before return
This commit is contained in:
commit
009a92f749
@ -100,11 +100,14 @@ static char* readFile(const char* filename, size_t* size) {
|
|||||||
buf = malloc(*size);
|
buf = malloc(*size);
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
fprintf(stderr, "malloc failed\n");
|
fprintf(stderr, "malloc failed\n");
|
||||||
|
fclose(f);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bytes_read = fread(buf, 1, *size, f);
|
bytes_read = fread(buf, 1, *size, f);
|
||||||
if (bytes_read != *size) {
|
if (bytes_read != *size) {
|
||||||
fprintf(stderr, "failed to read whole file\n");
|
fprintf(stderr, "failed to read whole file\n");
|
||||||
|
fclose(f);
|
||||||
free(buf);
|
free(buf);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user