[tracker] tracker-store: avoid NULL dereference in ptr



commit fe247b2577e7d4fd1b41a1ef43bbded2d0e6a576
Author: Aleksander Morgado <aleksander lanedo com>
Date:   Thu Jul 8 09:55:15 2010 +0200

    tracker-store: avoid NULL dereference in ptr

 src/tracker-store/tracker-resources.c |   35 +++++++++++++++++----------------
 1 files changed, 18 insertions(+), 17 deletions(-)
---
diff --git a/src/tracker-store/tracker-resources.c b/src/tracker-store/tracker-resources.c
index 70e051b..aecb51e 100644
--- a/src/tracker-store/tracker-resources.c
+++ b/src/tracker-store/tracker-resources.c
@@ -57,7 +57,7 @@
  * bytes plus DBusMessage's overhead. If that makes this number less
  * arbitrary for you, then fine.
  *
- * I really hope that the libdbus people get to their senses and 
+ * I really hope that the libdbus people get to their senses and
  * either stop doing their exit() nonsense in a library, and instead
  * return a clean DBusError or something, or create crystal clear
  * clarity about the maximum size of a message. And make it both so
@@ -214,28 +214,29 @@ query_callback (gpointer inthread_data, GError *error, gpointer user_data)
 	InThreadPtr *ptr = inthread_data;
 	TrackerDBusMethodInfo *info = user_data;
 
-	if (ptr && ptr->error) {
-		tracker_dbus_request_failed (info->request_id,
-		                             info->context,
-		                             &ptr->error,
-		                             NULL);
-		dbus_g_method_return_error (info->context, ptr->error);
-		g_error_free (ptr->error);
+	if (ptr) {
+		if (ptr->error) {
+			tracker_dbus_request_failed (info->request_id,
+			                             info->context,
+			                             &ptr->error,
+			                             NULL);
+			dbus_g_method_return_error (info->context, ptr->error);
+			g_error_free (ptr->error);
+		} else {
+			/* Success */
+			tracker_dbus_request_success (info->request_id,
+			                              info->context);
+
+			dbus_g_method_send_reply (info->context, ptr->reply);
+		}
+		g_slice_free (InThreadPtr, ptr);
 	} else if (error) {
 		tracker_dbus_request_failed (info->request_id,
 		                             info->context,
 		                             &error,
 		                             NULL);
 		dbus_g_method_return_error (info->context, error);
-	} else {
-		tracker_dbus_request_success (info->request_id,
-		                              info->context);
-
-		dbus_g_method_send_reply (info->context, ptr->reply);
-	}
-
-	if (ptr)
-		g_slice_free (InThreadPtr, ptr);
+	} /* else !ptr && !error */
 }
 
 static gpointer



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