summaryrefslogtreecommitdiffstats
path: root/binding
diff options
context:
space:
mode:
authorMatt Ranostay <matt.ranostay@konsulko.com>2018-10-08 15:39:37 +0800
committerMatt Ranostay <matt.ranostay@konsulko.com>2018-11-12 03:58:47 -0800
commit7cae41916496cd56bad7eebc3dac3f4c159d7734 (patch)
tree647ca4ec93a319a340e3cfa51e4ea830c8612a80 /binding
parent62a466a8934bd3240aa202bdf28103617220619b (diff)
binding: bluetooth: add check to be sure GError has been set
segfaults can happen if the dbus call reply fails but doesn't set a GError. Bug-AGL: SPEC-1630 Change-Id: I83ea2f7997a8fcef1cdd73a7df2cf9ad97e00d91 Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
Diffstat (limited to 'binding')
-rw-r--r--binding/bluetooth-api.c8
-rw-r--r--binding/bluetooth-api.h3
2 files changed, 7 insertions, 4 deletions
diff --git a/binding/bluetooth-api.c b/binding/bluetooth-api.c
index 4649067..2ac25eb 100644
--- a/binding/bluetooth-api.c
+++ b/binding/bluetooth-api.c
@@ -611,7 +611,7 @@ static void bluetooth_state(afb_req_t request)
jresp = adapter_properties(ns, &error, adapter);
if (!jresp) {
afb_req_fail_f(request, "failed", "property %s error %s",
- "State", error->message);
+ "State", BLUEZ_ERRMSG(error));
return;
}
@@ -639,7 +639,7 @@ static void bluetooth_adapter(afb_req_t request)
if (!reply) {
afb_req_fail_f(request, "failed",
"adapter %s method %s error %s",
- scan, "Scan", error->message);
+ scan, "Scan", BLUEZ_ERRMSG(error));
g_error_free(error);
return;
}
@@ -654,7 +654,7 @@ static void bluetooth_adapter(afb_req_t request)
if (!ret) {
afb_req_fail_f(request, "failed",
"adapter %s set_property %s error %s",
- adapter, "Discoverable", error->message);
+ adapter, "Discoverable", BLUEZ_ERRMSG(error));
g_error_free(error);
return;
}
@@ -668,7 +668,7 @@ static void bluetooth_adapter(afb_req_t request)
if (!ret) {
afb_req_fail_f(request, "failed",
"adapter %s set_property %s error %s",
- adapter, "Powered", error->message);
+ adapter, "Powered", BLUEZ_ERRMSG(error));
g_error_free(error);
return;
}
diff --git a/binding/bluetooth-api.h b/binding/bluetooth-api.h
index d8df0af..8ab8135 100644
--- a/binding/bluetooth-api.h
+++ b/binding/bluetooth-api.h
@@ -49,6 +49,9 @@
__tpath; \
})
+#define BLUEZ_ERRMSG(error) \
+ (error ? error->message : "unspecified")
+
#define FREEDESKTOP_INTROSPECT "org.freedesktop.DBus.Introspectable"
#define FREEDESKTOP_PROPERTIES "org.freedesktop.DBus.Properties"
#define FREEDESKTOP_OBJECTMANAGER "org.freedesktop.DBus.ObjectManager"