cmocka: Leave if expected_call is NULL
authorAndreas Schneider <asn@cryptomilk.org>
Mon, 7 Nov 2016 07:03:10 +0000 (08:03 +0100)
committerAndreas Schneider <asn@cryptomilk.org>
Mon, 7 Nov 2016 07:11:39 +0000 (08:11 +0100)
CID 1365415

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
src/cmocka.c

index e21ad26..6c79a20 100644 (file)
@@ -914,15 +914,16 @@ void _function_called(const char *const function,
 {
     ListNode *first_value_node = NULL;
     ListNode *value_node = NULL;
-    FuncOrderingValue *expected_call;
     int rc;
 
     rc = list_first(&global_call_ordering_head, &value_node);
     first_value_node = value_node;
     if (rc) {
+        FuncOrderingValue *expected_call;
         int cmp;
 
         expected_call = (FuncOrderingValue *)value_node->value;
+
         cmp = strcmp(expected_call->function, function);
         if (value_node->refcount < -1) {
             /*
@@ -948,7 +949,7 @@ void _function_called(const char *const function,
                     cmp = strcmp(expected_call->function, function);
                 }
 
-                if (value_node == first_value_node->prev) {
+                if (expected_call == NULL || value_node == first_value_node->prev) {
                     cm_print_error(SOURCE_LOCATION_FORMAT
                                    ": error: No expected mock calls matching "
                                    "called() invocation in %s",