Mercurial > trustbridge
changeset 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 | 00aa5fa3c2fb |
children | ee27186fc8e6 |
files | common/listutil.c |
diffstat | 1 files changed, 4 insertions(+), 1 deletions(-) [+] |
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) {