hfp_ag_bluez5: Fix sanity check
authorDenis Kenzior <denkenz@gmail.com>
Thu, 21 Mar 2013 15:19:00 +0000 (10:19 -0500)
committerDenis Kenzior <denkenz@gmail.com>
Thu, 21 Mar 2013 15:19:00 +0000 (10:19 -0500)
We should be checking that modems != NULL, not modems->data.  This is
because the list can be empty and we would crash.

plugins/hfp_ag_bluez5.c

index a81adfd..64ea8ca 100644 (file)
@@ -84,14 +84,14 @@ static DBusMessage *profile_new_connection(DBusConnection *conn,
        DBG("%s", device);
 
        /* Pick the first voicecall capable modem */
-       modem = modems->data;
-       if (modem == NULL) {
+       if (modems == NULL) {
                close(fd);
                return g_dbus_create_error(msg, BLUEZ_ERROR_INTERFACE
                                                ".Rejected",
                                                "No voice call capable modem");
        }
 
+       modem = modems->data;
        DBG("Picked modem %p for emulator", modem);
 
        em = ofono_emulator_create(modem, OFONO_EMULATOR_TYPE_HFP);