diff mbox series

[BlueZ,v2,8/9] gatt: proxy_property_changed: check for NULL iterator

Message ID 20220923145814.26077-3-ceggers@arri.de
State Superseded
Headers show
Series properties_changed: check for NULL iterator | expand

Commit Message

Christian Eggers Sept. 23, 2022, 2:58 p.m. UTC
The passed iterator can be NULL as in
src/gatt-database.c::properties_changed():
...
   proxy->prop_func(..., ..., iter=NULL, ...)
   +--client/gatt.c::property_changed_cb(..., ..., iter, ...);
      +--dbus_message_iter_get_arg_type(iter);
...
---
 src/gatt-database.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/src/gatt-database.c b/src/gatt-database.c
index c72f4a4d5c54..ea282d4bc193 100644
--- a/src/gatt-database.c
+++ b/src/gatt-database.c
@@ -2867,17 +2867,19 @@  static void property_changed_cb(GDBusProxy *proxy, const char *name,
 	if (strcmp(name, "Value"))
 		return;
 
-	if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_ARRAY) {
-		DBG("Malformed \"Value\" property received");
-		return;
-	}
+	if (iter) {
+		if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_ARRAY) {
+			DBG("Malformed \"Value\" property received");
+			return;
+		}
 
-	dbus_message_iter_recurse(iter, &array);
-	dbus_message_iter_get_fixed_array(&array, &value, &len);
+		dbus_message_iter_recurse(iter, &array);
+		dbus_message_iter_get_fixed_array(&array, &value, &len);
 
-	if (len < 0) {
-		DBG("Malformed \"Value\" property received");
-		return;
+		if (len < 0) {
+			DBG("Malformed \"Value\" property received");
+			return;
+		}
 	}
 
 	/* Truncate the value if it's too large */