Pārlūkot izejas kodu

[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 <rea-fbsd@codelabs.ru>
tags/v0.9.4
Eygene Ryabinkin 15 gadus atpakaļ
vecāks
revīzija
6de45ad4ae
1 mainītis faili ar 2 papildinājumiem un 1 dzēšanām
  1. 2
    1
      src/util/zbin.c

+ 2
- 1
src/util/zbin.c Parādīt failu

@@ -90,7 +90,8 @@ static int read_file ( const char *filename, void **buf, size_t *len ) {
90 90
 	return 0;
91 91
 
92 92
  err:
93
-	fclose ( file );
93
+	if ( file )
94
+		fclose ( file );
94 95
 	return -1;
95 96
 }
96 97
 

Notiek ielāde…
Atcelt
Saglabāt