gtestutils: Don’t free unassigned variables in an error path
authorPhilip Withnall <philip.withnall@collabora.co.uk>
Thu, 15 May 2014 09:15:26 +0000 (10:15 +0100)
committerPhilip Withnall <philip.withnall@collabora.co.uk>
Thu, 15 May 2014 13:35:19 +0000 (14:35 +0100)
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

index 002c2ae..88a6fc0 100644 (file)
@@ -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;
 }