[tracker/miner-fs-initable-iface] libtracker-miner, tracker-miner-fs: Protect potential NULL unrefs in finalize



commit 1e7c6e582a1d72d285dd100d16c69fe486bba101
Author: Martyn Russell <martyn lanedo com>
Date:   Wed Feb 2 17:13:06 2011 +0000

    libtracker-miner, tracker-miner-fs: Protect potential NULL unrefs in finalize

 src/libtracker-miner/tracker-miner-object.c |    4 ++-
 src/miners/fs/tracker-miner-files.c         |   29 ++++++++++++++++----------
 2 files changed, 21 insertions(+), 12 deletions(-)
---
diff --git a/src/libtracker-miner/tracker-miner-object.c b/src/libtracker-miner/tracker-miner-object.c
index 72b9a4e..d0ac599 100644
--- a/src/libtracker-miner/tracker-miner-object.c
+++ b/src/libtracker-miner/tracker-miner-object.c
@@ -903,7 +903,9 @@ miner_finalize (GObject *object)
 		g_object_unref (miner->private->connection);
 	}
 
-	g_hash_table_unref (miner->private->pauses);
+	if (miner->private->pauses) {
+		g_hash_table_unref (miner->private->pauses);
+	}
 
 	G_OBJECT_CLASS (tracker_miner_parent_class)->finalize (object);
 }
diff --git a/src/miners/fs/tracker-miner-files.c b/src/miners/fs/tracker-miner-files.c
index 5dadeb3..09496d2 100644
--- a/src/miners/fs/tracker-miner-files.c
+++ b/src/miners/fs/tracker-miner-files.c
@@ -623,11 +623,12 @@ miner_files_finalize (GObject *object)
 	mf = TRACKER_MINER_FILES (object);
 	priv = mf->private;
 
-	g_signal_handlers_disconnect_by_func (priv->config,
-	                                      low_disk_space_limit_cb,
-	                                      NULL);
-
-	g_object_unref (priv->config);
+	if (priv->config) {
+		g_signal_handlers_disconnect_by_func (priv->config,
+		                                      low_disk_space_limit_cb,
+		                                      NULL);
+		g_object_unref (priv->config);
+	}
 
 	disk_space_check_stop (TRACKER_MINER_FILES (object));
 
@@ -642,15 +643,21 @@ miner_files_finalize (GObject *object)
 	}
 
 #if defined(HAVE_UPOWER) || defined(HAVE_HAL)
-	g_object_unref (priv->power);
+	if (priv->power) {
+		g_object_unref (priv->power);
+	}
 #endif /* defined(HAVE_UPOWER) || defined(HAVE_HAL) */
 
-	g_object_unref (priv->storage);
+	if (priv->storage) {
+		g_object_unref (priv->storage);
+	}
 
-	g_signal_handlers_disconnect_by_func (priv->volume_monitor,
-	                                      mount_pre_unmount_cb,
-	                                      object);
-	g_object_unref (priv->volume_monitor);
+	if (priv->volume_monitor) {
+		g_signal_handlers_disconnect_by_func (priv->volume_monitor,
+		                                      mount_pre_unmount_cb,
+		                                      object);
+		g_object_unref (priv->volume_monitor);
+	}
 
 	if (priv->force_recheck_id) {
 		g_source_remove (priv->force_recheck_id);



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