Fix memory leaks in handling server requests.
authorMandeep Shetty <mandeep.shetty@intel.com>
Tue, 19 May 2015 17:35:46 +0000 (10:35 -0700)
committerErich Keane <erich.keane@intel.com>
Tue, 19 May 2015 21:49:11 +0000 (21:49 +0000)
Two memory leaks fixed. One after a response is sent and one when a
server request is deleted. malloc'ed tokens were not free'd in both
instances.

Change-Id: I125bab278dd8542ff5970e6655b24a5cbacfe7e9
Signed-off-by: Mandeep Shetty <mandeep.shetty@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1040
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Sakthivel Samidurai <sakthivel.samidurai@intel.com>
Reviewed-by: Erich Keane <erich.keane@intel.com>
resource/csdk/stack/src/ocserverrequest.c

index c3dabad..8448b87 100644 (file)
@@ -89,6 +89,7 @@ static void DeleteServerRequest(OCServerRequest * serverRequest)
     if(serverRequest)
     {
         LL_DELETE(serverRequestList, serverRequest);
+        OCFree(serverRequest->requestToken);
         OCFree(serverRequest);
         serverRequest = NULL;
         OC_LOG(INFO, TAG, PCF("Server Request Removed!!"));
@@ -606,6 +607,7 @@ OCStackResult HandleSingleResponse(OCEntityHandlerResponse * ehResponse)
     }
     #endif
 
+    OCFree(responseInfo.info.token);
     OCFree(responseInfo.info.options);
     //Delete the request
     FindAndDeleteServerRequest(serverRequest);