[IOT-2124] added NULL check after OICCalloc
authorsaurabh.s9 <saurabh.s9@samsung.com>
Sat, 20 May 2017 13:15:28 +0000 (18:45 +0530)
committerRandeep Singh <randeep.s@samsung.com>
Sun, 21 May 2017 08:28:56 +0000 (08:28 +0000)
Change-Id: I4013385beb5ba13fe8830f6b64a20f9562f0bdbf
Signed-off-by: saurabh.s9 <saurabh.s9@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/20175
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Randeep Singh <randeep.s@samsung.com>
resource/csdk/security/src/pstatresource.c

index a27e537..01ae91c 100644 (file)
@@ -627,6 +627,7 @@ static OCStackResult CBORPayloadToPstatBin(const uint8_t *cborPayload,
 
         pstat->smLen = 1;
         pstat->sm = (OicSecDpom_t*)OICCalloc(pstat->smLen, sizeof(OicSecDpom_t));
+        VERIFY_NOT_NULL(TAG, pstat->sm, ERROR);
         cborFindResult = cbor_value_get_int(&pstatMap, &sm);
         VERIFY_CBOR_SUCCESS(TAG, cborFindResult, "Failed Finding SM.");
         pstat->sm[0] = (OicSecDpom_t)sm;
@@ -644,6 +645,7 @@ static OCStackResult CBORPayloadToPstatBin(const uint8_t *cborPayload,
         VERIFY_NOT_NULL(TAG, gPstat, ERROR);
         pstat->smLen = gPstat->smLen;
         pstat->sm = (OicSecDpom_t*)OICCalloc(pstat->smLen, sizeof(OicSecDpom_t));
+        VERIFY_NOT_NULL(TAG, pstat->sm, ERROR);
         *pstat->sm = *gPstat->sm;
         cborFindResult = CborNoError;
     }