1
0
mirror of https://github.com/kgabis/parson.git synced 2025-01-14 06:12:54 +08:00

Fix memory leak

If `fread` fails, `file_contents` is leaked.  I’m just freeing the memory allocated :)
This commit is contained in:
Stephen Mathieson 2013-12-06 14:31:18 -05:00
parent 08a4396b32
commit 4413910346

View File

@ -161,6 +161,7 @@ static char * read_file(const char * filename) {
if (fread(file_contents, file_size, 1, fp) < 1) {
if (ferror(fp)) {
fclose(fp);
parson_free(file_contents);
return NULL;
}
}