From fa54ae42ccb3d8f911e00b02ed1e581537e47f79 Mon Sep 17 00:00:00 2001 From: Olivier Martin Date: Wed, 15 Sep 2021 22:35:10 +0200 Subject: [PATCH] handle_dbus_gattcharacteristic_from_path: Ensure 'characteristic_uuid_str' is not NULL --- dbus/gattlib_char.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dbus/gattlib_char.c b/dbus/gattlib_char.c index c6a6daf..309be40 100644 --- a/dbus/gattlib_char.c +++ b/dbus/gattlib_char.c @@ -35,6 +35,11 @@ static bool handle_dbus_gattcharacteristic_from_path(gattlib_context_t* conn_con if (uuid != NULL) { uuid_t characteristic_uuid; const gchar *characteristic_uuid_str = org_bluez_gatt_characteristic1_get_uuid(characteristic); + if (characteristic_uuid_str == NULL) { + // It should not be expected to get NULL from GATT characteristic UUID but we still test it + fprintf(stderr, "Error: %s path unexpectly returns a NULL UUID.\n", object_path); + return false; + } gattlib_string_to_uuid(characteristic_uuid_str, strlen(characteristic_uuid_str) + 1, &characteristic_uuid);