]> code.delx.au - pulseaudio/commitdiff
bluetooth: Fix crash in pa_bluetooth_discovery_get_device_by_address()
authorJoão Paulo Rechi Vita <jprvita@gmail.com>
Wed, 20 Nov 2013 21:21:36 +0000 (18:21 -0300)
committerTanu Kaskinen <tanu.kaskinen@linux.intel.com>
Fri, 22 Nov 2013 16:40:07 +0000 (18:40 +0200)
We need to check if the device information is valid first, so we don't
pass invalid strings to pa_streq().

src/modules/bluetooth/bluez5-util.c

index d2893c0a8d622bcd7a2eae3ce923cd9cb0b0878f..c7fb6ae5a4938096975a1e8f9b380574c3e293dc 100644 (file)
@@ -395,8 +395,8 @@ pa_bluetooth_device* pa_bluetooth_discovery_get_device_by_address(pa_bluetooth_d
     pa_assert(local);
 
     while ((d = pa_hashmap_iterate(y->devices, &state, NULL)))
-        if (pa_streq(d->address, remote) && pa_streq(d->adapter->address, local))
-            return d->device_info_valid == 1 ? d : NULL;
+        if (d->device_info_valid == 1 && pa_streq(d->address, remote) && pa_streq(d->adapter->address, local))
+            return d;
 
     return NULL;
 }