Fix static analysis issue in base layer.
authorJaehong Jo <jaehong.jo@samsung.com>
Thu, 9 Feb 2017 02:58:52 +0000 (11:58 +0900)
committerAshok Babu Channa <ashok.channa@samsung.com>
Mon, 13 Feb 2017 06:20:51 +0000 (06:20 +0000)
ocresource.c, ocstack.c

Change-Id: I8568bb8942eae29da646f7e9efa30d4f73fa9e07
Signed-off-by: Jaehong Jo <jaehong.jo@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/17133
Tested-by: jenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: Ashok Babu Channa <ashok.channa@samsung.com>
resource/csdk/stack/src/ocresource.c
resource/csdk/stack/src/ocstack.c

index cd74b4c149efe7a0d7d2d6fe79c189db50e9f1ea..ea2f0454f0fcea7b917f01bb6c62bc276083177f 100755 (executable)
@@ -1377,7 +1377,6 @@ static OCStackResult HandleVirtualResource (OCServerRequest *request, OCResource
     OCPayload* payload = NULL;
     char *interfaceQuery = NULL;
     char *resourceTypeQuery = NULL;
-    char *dataModelVersions = NULL;
 
     OIC_LOG(INFO, TAG, "Entering HandleVirtualResource");
 
@@ -1619,10 +1618,7 @@ exit:
         OICFree(resourceTypeQuery);
     }
     OCPayloadDestroy(payload);
-    if (dataModelVersions)
-    {
-        OICFree(dataModelVersions);
-    }
+
     // To ignore the message, OC_STACK_CONTINUE is sent
     return discoveryResult;
 }
index 7744dc23f07b54ce3499226eb14b9a34eb432306..6bb5d277e657dd37b77a0edfa6de2261679baaaf 100644 (file)
@@ -1574,11 +1574,14 @@ void OCHandleResponse(const CAEndpoint_t* endPoint, const CAResponseInfo_t* resp
             else
             {
 #ifdef RD_CLIENT
-                // if request uri is '/oic/rd', update ins value of resource.
-                char *targetUri = strstr(cbNode->requestUri, OC_RSRVD_RD_URI);
-                if (targetUri)
+                if (cbNode->requestUri)
                 {
-                    OCUpdateResourceInsWithResponse(cbNode->requestUri, response);
+                    // if request uri is '/oic/rd', update ins value of resource.
+                    char *targetUri = strstr(cbNode->requestUri, OC_RSRVD_RD_URI);
+                    if (targetUri)
+                    {
+                        OCUpdateResourceInsWithResponse(cbNode->requestUri, response);
+                    }
                 }
 #endif
                 // set remoteID(device ID) into OCClientResponse callback parameter
@@ -3778,8 +3781,11 @@ OCStackResult OCUnBindResource(
             {
                 OCChildResource *temp = tempChildResource->next;
                 OICFree(tempChildResource);
-                tempLastChildResource->next = temp;
-                temp = NULL;
+                if (tempLastChildResource)
+                {
+                    tempLastChildResource->next = temp;
+                    temp = NULL;
+                }
             }
 
             OIC_LOG(INFO, TAG, "resource unbound");
@@ -4733,12 +4739,12 @@ OCStackResult deleteResource(OCResource *resource)
                 headResource = temp->next;
             }
             // Deleting tail.
-            else if (temp == tailResource)
+            else if (temp == tailResource && prev)
             {
                 tailResource = prev;
                 tailResource->next = NULL;
             }
-            else
+            else if (prev)
             {
                 prev->next = temp->next;
             }