service : Fix put data on null pointer
authorThierry Boureille <thierry.boureille@gmail.com>
Thu, 28 Jul 2011 00:35:05 +0000 (02:35 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Thu, 28 Jul 2011 11:06:37 +0000 (13:06 +0200)
when using ConnectService of Manager interface a segfault arises due
to a null pointer.

in __connman_service_create_and_connect:

[...]
service = lookup_by_identifier(name);

if (service != NULL)
goto done;

network = create_hidden_wifi(device, ssid, mode, security);
if (network != NULL) {
connman_network_set_group(network, group);
service->network_created = TRUE;
}
[...]
in this part "service" is null

src/service.c

index d442c16..1939832 100644 (file)
@@ -4206,10 +4206,8 @@ int __connman_service_create_and_connect(DBusMessage *msg)
                goto done;
 
        network = create_hidden_wifi(device, ssid, mode, security);
-       if (network != NULL) {
+       if (network != NULL)
                connman_network_set_group(network, group);
-               service->network_created = TRUE;
-       }
 
        service = lookup_by_identifier(name);
 
@@ -4222,6 +4220,8 @@ done:
                goto failed;
        }
 
+       service->network_created = TRUE;
+
        if (is_connected(service) == TRUE) {
                err = -EISCONN;
                goto failed;