AT: Always check there is a sync request before testing its members
authorPaul Kocialkowski <contact@paulk.fr>
Fri, 27 Jul 2012 22:32:20 +0000 (00:32 +0200)
committerPaul Kocialkowski <contact@paulk.fr>
Fri, 27 Jul 2012 22:32:20 +0000 (00:32 +0200)
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
at.c

diff --git a/at.c b/at.c
index 6b55f8e..7a02458 100644 (file)
--- a/at.c
+++ b/at.c
@@ -905,7 +905,7 @@ int at_response_expect_status(struct at_response *response)
                return -1;
 
        // If we get an unsol response while we expect a status, there is something going wrong
-       if(response->command != NULL) {
+       if(response->command != NULL && at_responses_handling.sync_request != NULL && at_responses_handling.sync_request->command != NULL) {
                rc = at_commands_compare(response->command, at_responses_handling.sync_request->command);
                if(!rc) {
                        // Only unlock is there is no async request waiting with this command (if it is unsol)!
@@ -917,7 +917,7 @@ int at_response_expect_status(struct at_response *response)
                }
        }
 
-       if(response->status == AT_STATUS_UNDEF) {
+       if(response->status == AT_STATUS_UNDEF && at_responses_handling.sync_request != NULL && at_responses_handling.sync_request->command != NULL) {
                if((response->data == NULL || response->data_count <= 0) && response->command != NULL) {
                        rc = at_commands_compare(response->command, at_responses_handling.sync_request->command);
                        if(rc) {