[glib] gerror: Don't leak when warning about overwriting an error



commit 267222873399cadb0feef4009b26fb1109453fcd
Author: Stef Walter <stefw gnome org>
Date:   Thu Oct 31 14:39:05 2013 +0100

    gerror: Don't leak when warning about overwriting an error
    
    While not strictly necessary, this fixes a false positive
    leak in the tests.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=627423

 glib/gerror.c |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)
---
diff --git a/glib/gerror.c b/glib/gerror.c
index 2adbdf8..809d0c9 100644
--- a/glib/gerror.c
+++ b/glib/gerror.c
@@ -587,16 +587,13 @@ g_set_error_literal (GError      **err,
                      gint          code,
                      const gchar  *message)
 {
-  GError *new;
-
   if (err == NULL)
     return;
 
-  new = g_error_new_literal (domain, code, message);
   if (*err == NULL)
-    *err = new;
+    *err = g_error_new_literal (domain, code, message);
   else
-    g_warning (ERROR_OVERWRITTEN_WARNING, new->message); 
+    g_warning (ERROR_OVERWRITTEN_WARNING, message);
 }
 
 /**


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