This patch fixes a segfault caused by a race condition where an incoming request has just been accepted and allocated, but a device for it has yet to be opened, and an old request is closed. The checks prevent a strcmp against unexisting devices. diff -uNr libqmi-1.8.0/src/libqmi-glib/qmi-proxy.c libqmi-qmi-proxy-segfault/src/libqmi-glib/qmi-proxy.c --- libqmi-1.8.0/src/libqmi-glib/qmi-proxy.c 2013-09-13 17:16:12.000000000 +0000 +++ libqmi-qmi-proxy-segfault/src/libqmi-glib/qmi-proxy.c 2014-04-10 10:45:18.423512719 +0000 @@ -142,8 +142,8 @@ for (l = self->priv->clients; l; l = g_list_next (l)) { Client *client = l->data; - if (device == client->device || - g_str_equal (qmi_device_get_path (device), qmi_device_get_path (client->device))) + if (client->device && (device == client->device || + g_str_equal (qmi_device_get_path (device), qmi_device_get_path (client->device)))) n++; } @@ -171,8 +171,8 @@ for (l = self->priv->devices; l; l = g_list_next (l)) { QmiDevice *device_in_list = QMI_DEVICE (l->data); - if (device == device_in_list || - g_str_equal (qmi_device_get_path (device), qmi_device_get_path (device_in_list))) { + if (device_in_list && (device == device_in_list || + g_str_equal (qmi_device_get_path (device), qmi_device_get_path (device_in_list)))) { g_debug ("closing device '%s': no longer used", qmi_device_get_path_display (device)); qmi_device_close (device_in_list, NULL); g_object_unref (device_in_list);