dtinfo/dtinfogen: Fix segfault introduced by over zealously fixing coverity resource...
authorPeter Howkins <flibble@users.sf.net>
Thu, 5 Apr 2018 17:16:10 +0000 (18:16 +0100)
committerPeter Howkins <flibble@users.sf.net>
Thu, 5 Apr 2018 17:16:10 +0000 (18:16 +0100)
cde/programs/dtinfo/dtinfogen/infolib/etc/SearchPath.C

index 1323505e735c29e35dee931e423d74a1aa071525..095c69091c497c63b3142fd6851e95cbe29ddc32 100644 (file)
@@ -128,7 +128,7 @@ char *
 SearchPath::get_real_path( const char *file_name )
 {
   CC_TPtrSlistIterator<CC_String> path_it( *search_path_table );
-  FILE *fp;
+  FILE *fp = NULL;
 
   if (file_name == NULL || *file_name == '\0')
     return NULL;
@@ -149,7 +149,9 @@ SearchPath::get_real_path( const char *file_name )
       fclose( fp );
       return ( full_path_name );
     }
-    fclose( fp );
+    if(fp) {
+      fclose( fp );
+    }
   }
 
   return NULL;