Fix memory leak in SSM Sensor Processor
authorAnkur Bansal <ankur.b1@samsung.com>
Thu, 2 Jul 2015 13:09:17 +0000 (18:39 +0530)
committerUze Choi <uzchoi@samsung.com>
Mon, 6 Jul 2015 01:17:52 +0000 (01:17 +0000)
Fix memory leak in CResourceFinder::onExecute. Delete resource handler
in case of Error.

Change-Id: I3d2363ed0b2585ffcbc403417fd73f60e89f1a88
Signed-off-by: Ankur Bansal <ankur.b1@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1490
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Minji Park <minjii.park@samsung.com>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
service/soft-sensor-manager/SSMCore/src/SensorProcessor/ResourceFinder.cpp

index 2747458..bf962b6 100644 (file)
@@ -192,7 +192,13 @@ void CResourceFinder::onExecute(void *pArg)
         case RESOURCE_DISCOVER_REQUESTPROFILE:
             pResource = (std::shared_ptr< OC::OCResource > *) pMessage[1];
             pResourceHandler = new OICResourceHandler();
-            SSM_CLEANUP_ASSERT(pResourceHandler->initHandler(*pResource, this));
+
+            res = pResourceHandler->initHandler(*pResource, this);
+            if(res != SSM_S_OK)
+            {
+                SAFE_DELETE(pResourceHandler);
+                SSM_CLEANUP_ASSERT(res);
+            }
 
             resourceFullPath = pResource->get()->host() + pResource->get()->uri();