[glib] gtestutils: Don’t free unassigned variable s in an error path



commit 46b7217fbf02b679749cf1d042ecc57504a3b97c
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Thu May 15 10:15:26 2014 +0100

    gtestutils: Don’t free unassigned variables in an error path
    
    If the stream is invalid, msg.nums and msg.strings have not been
    assigned to, so don’t free them.
    
    Coverity issue: #1159505

 glib/gtestutils.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/glib/gtestutils.c b/glib/gtestutils.c
index 002c2ae..88a6fc0 100644
--- a/glib/gtestutils.c
+++ b/glib/gtestutils.c
@@ -3057,9 +3057,11 @@ g_test_log_extract (GTestLogBuffer *tbuffer)
           tbuffer->msgs = g_slist_prepend (tbuffer->msgs, g_memdup (&msg, sizeof (msg)));
           return TRUE;
         }
+
+      g_free (msg.nums);
+      g_strfreev (msg.strings);
     }
-  g_free (msg.nums);
-  g_strfreev (msg.strings);
+
   g_error ("corrupt log stream from test program");
   return FALSE;
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]