Fix fread error handling.

This commit is contained in:
Michael Drake 2014-05-26 14:03:20 +01:00
parent 2aeec1a18c
commit 1f337f292d
2 changed files with 4 additions and 1 deletions

View File

@ -138,6 +138,7 @@ read_providers(const char *fname,
if (fread(providersd, 1, fsize, providersf) != fsize) { if (fread(providersd, 1, fsize, providersf) != fsize) {
fclose(providersf); fclose(providersf);
free(providersd); free(providersd);
return NSERROR_BAD_SIZE;
} }
providersd[fsize] = 0; /* ensure null terminated */ providersd[fsize] = 0; /* ensure null terminated */

View File

@ -75,7 +75,9 @@ typedef enum {
NSERROR_PERMISSION, /**< Permission error */ NSERROR_PERMISSION, /**< Permission error */
NSERROR_NOSPACE /**< Insufficient space */ NSERROR_NOSPACE, /**< Insufficient space */
NSERROR_BAD_SIZE /**< Bad size */
} nserror; } nserror;
#endif #endif