[PATCH v1 2/6] TraceReaderLogQEMU.cc: Fix resource leak

Ryan Long ryan.long at oarcorp.com
Fri May 28 20:08:14 UTC 2021


CID 1399615: Resource leak in processFile().

Closes #4419
---
 tester/covoar/TraceReaderLogQEMU.cc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tester/covoar/TraceReaderLogQEMU.cc b/tester/covoar/TraceReaderLogQEMU.cc
index 508074a..b64a149 100644
--- a/tester/covoar/TraceReaderLogQEMU.cc
+++ b/tester/covoar/TraceReaderLogQEMU.cc
@@ -109,12 +109,12 @@ namespace Trace {
       return false;
     }
 
-
     //
     //  Discard Header section
     //
     if (! ReadUntilFound( logFile, QEMU_LOG_SECTION_END ) ) {
       fprintf( stderr, "Unable to locate end of log file header\n" );
+      fclose( logFile );
       return false;
     }
 
@@ -123,6 +123,7 @@ namespace Trace {
     //
     if (! ReadUntilFound( logFile, QEMU_LOG_IN_KEY )){
       fprintf(stderr,"Error: Unable to locate first IN: Block in Log file \n");
+      fclose( logFile );
       return false;
     }
 
-- 
1.8.3.1



More information about the devel mailing list