From: Eygene Ryabinkin Date: Sun, 31 Aug 2008 18:17:30 +0000 (+0400) Subject: [util] Avoid calling fclose(NULL) in zbin.c X-Git-Tag: v0.9.4~29 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6de45ad4ae65d1754abaee4d5e92851b7b40c9b5;p=thirdparty%2Fipxe.git [util] Avoid calling fclose(NULL) in zbin.c Must check that argument to a fclose() is not NULL -- we can get to the 'err' label when file was not opened. fclose(NULL) is known to produce core dump on some platforms and we don't want zbin to fail so loudly. Signed-off-by: Eygene Ryabinkin --- diff --git a/src/util/zbin.c b/src/util/zbin.c index f47fa36ba..b24f401eb 100644 --- a/src/util/zbin.c +++ b/src/util/zbin.c @@ -90,7 +90,8 @@ static int read_file ( const char *filename, void **buf, size_t *len ) { return 0; err: - fclose ( file ); + if ( file ) + fclose ( file ); return -1; }