[gnome-bluetooth] lib: check if an adapter is present before trying to register the agent



commit ad2395b45c777b6ff598470d3c389a2ad8b708a2
Author: Daniele Forsi <dforsi src gnome org>
Date:   Tue Apr 24 14:59:22 2012 +0200

    lib: check if an adapter is present before trying to register the agent
    
    Fixes the following warnings and segfault when running test-agent with no
    adapter present:
    (process:5950): GLib-GIO-CRITICAL **: g_dbus_proxy_get_object_path: assertion `G_IS_DBUS_PROXY (proxy)' failed
    
    (process:5950): GLib-CRITICAL **: g_path_get_basename: assertion `file_name != NULL' failed
    
    (process:5950): GLib-GIO-CRITICAL **: g_dbus_connection_register_object: assertion `object_path != NULL && g_variant_is_object_path (object_path)' failed
    
    Program received signal SIGSEGV, Segmentation fault.
    0xb7fc943c in bluetooth_agent_register (agent=0x8053420) at bluetooth-agent.c:462
    462			g_warning ("Failed to register object: %s", error->message);
    (gdb) print error
    $1 = (GError *) 0x0
    (gdb)
    
    https://bugzilla.gnome.org/show_bug.cgi?id=674720

 lib/bluetooth-agent.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
---
diff --git a/lib/bluetooth-agent.c b/lib/bluetooth-agent.c
index 83def10..35d381a 100644
--- a/lib/bluetooth-agent.c
+++ b/lib/bluetooth-agent.c
@@ -447,6 +447,9 @@ gboolean bluetooth_agent_register(BluetoothAgent *agent)
 
 	priv->adapter = get_default_adapter ();
 
+	if (priv->adapter == NULL)
+		return FALSE;
+
 	path = g_path_get_basename(g_dbus_proxy_get_object_path(priv->adapter));
 	priv->path = g_strdup_printf("/org/bluez/agent/%s", path);
 	g_free(path);



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