[glib/wip/gcleanup] gerror: WIP Fix more error overwriting and memory access problems



commit f6c6d89e62e3c6288cbbc235935abf83af3ca997
Author: Stef Walter <stefw gnome org>
Date:   Thu Nov 7 22:38:52 2013 +0100

    gerror: WIP Fix more error overwriting and memory access problems

 glib/gerror.c      |   10 ++++++++--
 glib/tests/error.c |    3 ---
 2 files changed, 8 insertions(+), 5 deletions(-)
---
diff --git a/glib/gerror.c b/glib/gerror.c
index 809d0c9..81e6b71 100644
--- a/glib/gerror.c
+++ b/glib/gerror.c
@@ -563,7 +563,10 @@ g_set_error (GError      **err,
   if (*err == NULL)
     *err = new;
   else
-    g_warning (ERROR_OVERWRITTEN_WARNING, new->message); 
+    {
+      g_warning (ERROR_OVERWRITTEN_WARNING, new->message);
+      g_error_free (new);
+    }
 }
 
 /**
@@ -619,7 +622,10 @@ g_propagate_error (GError **dest,
   else
     {
       if (*dest != NULL)
-        g_warning (ERROR_OVERWRITTEN_WARNING, src->message);
+        {
+          g_warning (ERROR_OVERWRITTEN_WARNING, src->message);
+          g_error_free (src);
+        }
       else
         *dest = src;
     }
diff --git a/glib/tests/error.c b/glib/tests/error.c
index 81b4055..ebbd965 100644
--- a/glib/tests/error.c
+++ b/glib/tests/error.c
@@ -28,10 +28,7 @@ test_overwrite (void)
   g_test_assert_expected_messages ();
 
   g_assert_error (dest, G_MARKUP_ERROR, G_MARKUP_ERROR_EMPTY);
-  g_assert_error (src, G_MARKUP_ERROR, G_MARKUP_ERROR_PARSE);
   g_error_free (dest);
-  g_error_free (src);
-
 }
 
 static void


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