From b82be455b458b5dfe5a667bd87b2fae45e6553c6 Mon Sep 17 00:00:00 2001 From: tswaehn Date: Fri, 4 Mar 2022 10:21:16 +0100 Subject: [PATCH] fix: sigsev when service is null --- dbus/gattlib.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/dbus/gattlib.c b/dbus/gattlib.c index 18fa960..282ff5d 100644 --- a/dbus/gattlib.c +++ b/dbus/gattlib.c @@ -669,7 +669,17 @@ static void add_characteristics_from_service(gattlib_context_t* conn_context, GD continue; } - if (strcmp(org_bluez_gatt_characteristic1_get_service(characteristic), service_object_path)) { + const gchar * property_value = org_bluez_gatt_characteristic1_get_service(characteristic); + if (property_value == NULL){ + if (error) { + GATTLIB_LOG(GATTLIB_ERROR, "Failed to get service '%s': %s", object_path, error->message); + g_error_free(error); + } else { + GATTLIB_LOG(GATTLIB_ERROR, "Failed to get service '%s'.", object_path); + } + continue; + } + if (strcmp(property_value, service_object_path)) { g_object_unref(characteristic); continue; } else {