fix: sigsev when service property returns null

pull/248/head
tswaehn 2022-03-04 09:35:13 +01:00 committed by Olivier Martin
parent 2448da5410
commit 5badee94b9
1 changed files with 11 additions and 1 deletions

View File

@ -408,7 +408,17 @@ int gattlib_discover_primary(gatt_connection_t* connection, gattlib_primary_serv
}
// Ensure the service is attached to this device
if (strcmp(conn_context->device_object_path, org_bluez_gatt_service1_get_device(service_proxy))) {
const gchar * service_property = org_bluez_gatt_service1_get_device(service_proxy);
if (service_property == NULL) {
if (error) {
GATTLIB_LOG(GATTLIB_ERROR, "Failed to get service property '%s': %s", object_path, error->message);
g_error_free(error);
} else {
GATTLIB_LOG(GATTLIB_ERROR, "Failed to get service property '%s'.", object_path);
}
continue;
}
if (strcmp(conn_context->device_object_path, service_property)) {
g_object_unref(service_proxy);
continue;
}