# HG changeset patch # User Bernhard Reiter # Date 1395157060 -3600 # Node ID 4f79cf9937374787d253a9678686e87666675941 # Parent e4088afd528180b882d8900f4d5df5adf8ff90a9 Tiny improvement: free resources first that you have aquired last. Added TODO for better error reporting. diff -r e4088afd5281 -r 4f79cf993737 common/listutil.c --- a/common/listutil.c Tue Mar 18 14:23:30 2014 +0000 +++ b/common/listutil.c Tue Mar 18 16:37:40 2014 +0100 @@ -77,8 +77,8 @@ } if (fread(*data, 1, *size, f) != *size) { + free(*data); fclose(f); - free(*data); return READ_FILE_READ_FAILED; } @@ -182,9 +182,11 @@ return TooLarge; } if (ret == READ_FILE_UNREADABLE) { + /* TODO: work with errno ? */ return SeekFailed; } if (ret == READ_FILE_READ_FAILED) { + /* TODO: work with ferror() or feof() ? */ return ReadFailed; } return UnknownError;