]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[util] Avoid calling fclose(NULL) in zbin.c
authorEygene Ryabinkin <rea-fbsd@codelabs.ru>
Sun, 31 Aug 2008 18:17:30 +0000 (22:17 +0400)
committerMichael Brown <mcb30@etherboot.org>
Thu, 4 Sep 2008 10:29:37 +0000 (11:29 +0100)
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 <rea-fbsd@codelabs.ru>
src/util/zbin.c

index f47fa36ba5f18b3ee4f605f46d86762d86e40798..b24f401eb8a4535355aeb77c0570df62d4567613 100644 (file)
@@ -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;
 }