Network: only strdup when there is actually data
authorPaul Kocialkowski <contact@paulk.fr>
Tue, 31 Jul 2012 21:12:24 +0000 (23:12 +0200)
committerPaul Kocialkowski <contact@paulk.fr>
Tue, 31 Jul 2012 21:12:24 +0000 (23:12 +0200)
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
network.c

index 6b24467..62d359d 100644 (file)
--- a/network.c
+++ b/network.c
@@ -182,8 +182,10 @@ int at_creg_handle(char **registration_state, struct at_response_data **response
        }
 
        asprintf(&(registration_state[0]), "%d", state);
-       registration_state[1] = strdup(lac);
-       registration_state[2] = strdup(cid);
+       if(lac != NULL)
+               registration_state[1] = strdup(lac);
+       if(cid != NULL)
+               registration_state[2] = strdup(cid);
 
        return 0;
 }