Fix for defects detected by static analysis in ca common logic
authorhyuna0213.jo <hyuna0213.jo@samsung.com>
Tue, 23 Feb 2016 09:41:42 +0000 (18:41 +0900)
committerJon A. Cruz <jonc@osg.samsung.com>
Wed, 24 Feb 2016 02:00:51 +0000 (02:00 +0000)
return value of 'OICCalloc' function is dereferenced
at cainterfacecontroller.c

Change-Id: I7c6513c72fe0e0f4ec24121cdc9e3e78ffa0cb41
Signed-off-by: hyuna0213.jo <hyuna0213.jo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/5143
Reviewed-by: jihwan seo <jihwan.seo@samsung.com>
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Jon A. Cruz <jonc@osg.samsung.com>
resource/csdk/connectivity/src/cainterfacecontroller.c

index bec1151..5e3e238 100644 (file)
@@ -247,7 +247,18 @@ CAResult_t CAGetNetworkInfo(CAEndpoint_t **info, uint32_t *size)
     }
 
     CAEndpoint_t **tempInfo = (CAEndpoint_t**) OICCalloc(g_numberOfAdapters, sizeof(*tempInfo));
+    if (!tempInfo)
+    {
+        OIC_LOG(ERROR, TAG, "Out of memory!");
+        return CA_MEMORY_ALLOC_FAILED;
+    }
     uint32_t *tempSize =(uint32_t*) OICCalloc(g_numberOfAdapters, sizeof(*tempSize));
+    if (!tempSize)
+    {
+        OIC_LOG(ERROR, TAG, "Out of memory!");
+        OICFree(tempInfo);
+        return CA_MEMORY_ALLOC_FAILED;
+    }
 
     CAResult_t res = CA_STATUS_FAILED;
     size_t resSize = 0;