[gnome-system-log/gnome-3-8] manager: add some safety NULL-checks



commit 78109b50ee76da3c09cd2d507ba68ee1146ded5a
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Thu Apr 11 17:25:20 2013 -0400

    manager: add some safety NULL-checks
    
    https://bugzilla.gnome.org/show_bug.cgi?id=697790

 src/logview-loglist.c | 11 +++++++----
 src/logview-manager.c |  4 ++++
 2 files changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/src/logview-loglist.c b/src/logview-loglist.c
index 73c8771..c796a6a 100644
--- a/src/logview-loglist.c
+++ b/src/logview-loglist.c
@@ -136,7 +136,8 @@ logview_loglist_find_log (LogviewLoglist *list, LogviewLog *log)
     if (current == log) {
       retval = gtk_tree_iter_copy (&iter);
     }
-    g_object_unref (current);
+    if (current)
+      g_object_unref (current);
   } while (gtk_tree_model_iter_next (model, &iter) != FALSE && retval == NULL);
 
   return retval;
@@ -488,10 +489,12 @@ logview_loglist_update_lines (LogviewLoglist *loglist, LogviewLog *log)
   g_assert (LOGVIEW_IS_LOGLIST (loglist));
   g_assert (LOGVIEW_IS_LOG (log));
 
-  days = logview_log_get_days_for_cached_lines (log);
   parent = logview_loglist_find_log (loglist, log);
-  update_days_and_lines_for_log (loglist, parent, days);
 
-  gtk_tree_iter_free (parent);
+  if (parent) {
+    days = logview_log_get_days_for_cached_lines (log);
+    update_days_and_lines_for_log (loglist, parent, days);
+    gtk_tree_iter_free (parent);
+  }
 }
 
diff --git a/src/logview-manager.c b/src/logview-manager.c
index 29dcba9..b948bfa 100644
--- a/src/logview-manager.c
+++ b/src/logview-manager.c
@@ -398,6 +398,10 @@ logview_manager_close_active_log (LogviewManager *manager)
   g_assert (LOGVIEW_IS_MANAGER (manager));
 
   active_log = manager->priv->active_log;
+  if (active_log == NULL) {
+    return;
+  }
+
   log_uri = logview_log_get_uri (active_log);
   file = logview_log_get_gfile (active_log);
 


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