Fix memory leak 99/25299/3
authorInho Oh <webispy@gmail.com>
Fri, 1 Dec 2017 07:06:06 +0000 (16:06 +0900)
committerMats Wichmann <mats@linux.com>
Thu, 7 Jun 2018 12:39:50 +0000 (12:39 +0000)
This patch fix critical memory leak. When I run CTT with CT1.2.3 test
case, memory is increased every time.

Change-Id: Idee5e3ed9b043a21d55ba5dc752c537156d99d8e
Signed-off-by: Inho Oh <webispy@gmail.com>
resource/csdk/security/src/aclresource.c
resource/csdk/stack/src/ocresource.c

index ab242d6..af7ae0f 100644 (file)
@@ -1763,6 +1763,7 @@ static OicSecAcl_t* CBORPayloadToAclVersionOpt(const uint8_t *cborPayload, const
                                                 }
 
                                                 free(subjectTag);       // we are done with this instance
+                                                subjectTag = NULL;
                                             }
 
                                             // advance to next elt in subject map
index 4242249..41d335b 100644 (file)
@@ -1219,6 +1219,8 @@ OCStackResult BuildIntrospectionResponseRepresentation(const OCResource *resourc
 
                         char *epStr = OCCreateEndpointStringFromCA(&caEps[i]);
                         urlInfoPayload[dimensions[0]] = BuildUrlInfoWithProtocol(proto, epStr);
+                        OICFree(epStr);
+                        OICFree(proto);
                         if (!urlInfoPayload[dimensions[0]])
                         {
                             OIC_LOG(ERROR, TAG, "Unable to build urlInfo object for protocol");
@@ -1264,6 +1266,11 @@ exit:
         }
     }
 
+    if (caEps)
+    {
+        OICFree(caEps);
+    }
+
     return OC_STACK_OK;
 }
 
@@ -1906,6 +1913,7 @@ static OCStackResult HandleVirtualResource (OCServerRequest *request, OCResource
     {
         OIC_LOG_V(ERROR, TAG, "Resource : %s not permitted for method: %d",
             request->resourceUrl, request->method);
+        DeleteServerRequest (request);
         return OC_STACK_UNAUTHORIZED_REQ;
     }