[gnome-logs] Avoid double frees on journal errors



commit dc85cbd673b3af6365a5ae5a49ebb67d3461a41d
Author: David King <davidk gnome org>
Date:   Tue Dec 8 17:54:57 2015 +0000

    Avoid double frees on journal errors
    
    NULL out the pointers to already-freed data when an error occurs in
    _gl_journal_query_entry().

 src/gl-journal.c |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
---
diff --git a/src/gl-journal.c b/src/gl-journal.c
index 80587d6..2b45ab0 100644
--- a/src/gl-journal.c
+++ b/src/gl-journal.c
@@ -409,6 +409,7 @@ _gl_journal_query_entry (GlJournal *self)
         g_warning ("Error while getting message from catalog: %s",
                    g_strerror (-ret));
         free (entry->cursor);
+        entry->cursor = NULL;
         goto out;
     }
 
@@ -419,7 +420,9 @@ _gl_journal_query_entry (GlJournal *self)
         g_warning ("%s", error->message);
         g_clear_error (&error);
         free (entry->cursor);
+        entry->cursor = NULL;
         free (entry->catalog);
+        entry->catalog = NULL;
         goto out;
     }
 
@@ -430,8 +433,11 @@ _gl_journal_query_entry (GlJournal *self)
         g_warning ("%s", error->message);
         g_clear_error (&error);
         free (entry->cursor);
+        entry->cursor = NULL;
         free (entry->catalog);
+        entry->catalog = NULL;
         g_free (entry->message);
+        entry->message = NULL;
         goto out;
     }
 


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