Fix use of uninitialized variable
authorErich Keane <erich.keane@intel.com>
Thu, 11 Sep 2014 17:57:44 +0000 (10:57 -0700)
committerErich Keane <erich.keane@intel.com>
Thu, 11 Sep 2014 17:57:44 +0000 (10:57 -0700)
If ctx == NULL, then VERIFY_NON_NULL would goto exit, which would then
OCFree the uninitialized variables.

Found by Clang:

occoap.c:274:5: warning: variable 'rcvObserveOption' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
occoap.c:44:36: note: expanded from macro 'VERIFY_NON_NULL'
 #define VERIFY_NON_NULL(arg) { if (!arg) {OC_LOG_V(FATAL, TAG, "%s is NULL", #arg); goto exit;} }
                                    ^~~~
occoap.c:459:16: note: uninitialized use occurs here

--Erich: rebase on master

Change-Id: Ie829c6ac284dfd988eeeffad446d9872424e604a
Signed-off-by: Thiago Macieira <thiago.macieira@intel.com>
csdk/occoap/src/occoap.c

index 9e952b7..19dfa3f 100644 (file)
@@ -255,8 +255,8 @@ static void HandleCoAPResponses(struct coap_context_t *ctx,
     OCClientResponse * clientResponse = NULL;
     ClientCB * cbNode = NULL;
     unsigned char * bufRes = NULL;
-    uint8_t * rcvObserveOption;
-    uint8_t * rcvMaxAgeOption;
+    uint8_t * rcvObserveOption = NULL;
+    uint8_t * rcvMaxAgeOption = NULL;
     uint32_t sequenceNumber = 0;
     uint32_t maxAge = 0;
     OCStackResult result = OC_STACK_ERROR;