Mercurial > trustbridge
diff common/listutil.c @ 38:fc6241283474
Fix resource leak when file too large
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Fri, 14 Mar 2014 09:05:11 +0000 |
parents | 37fc66967517 |
children | 5cb1eb928253 |
line wrap: on
line diff
--- a/common/listutil.c Fri Mar 14 09:01:19 2014 +0000 +++ b/common/listutil.c Fri Mar 14 09:05:11 2014 +0000 @@ -65,12 +65,15 @@ fseek(f, 0, SEEK_SET); if (file_size + 1 == 0) { + fclose(f); return READ_FILE_TOO_LARGE; } *size = (size_t) file_size; - if (*size > max_size) + if (*size > max_size) { + fclose(f); return READ_FILE_TOO_LARGE; + } *data = (char *) malloc( *size + 1 ); if (data == NULL) {