Fix memory leak in SSM executeContextQuery.
authorAnkur Bansal <ankur.b1@samsung.com>
Sat, 4 Jul 2015 07:48:46 +0000 (13:18 +0530)
committerUze Choi <uzchoi@samsung.com>
Mon, 6 Jul 2015 02:42:30 +0000 (02:42 +0000)
Update logic in CQueryEngine::executeContextQuery to free
clsContextQuery in case of error.

Change-Id: Ife66485b61a5f64ff5f190787482cdf6737850dd
Signed-off-by: Ankur Bansal <ankur.b1@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1519
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/QueryProcessor/QueryEngine.cpp

index 4d2a117..765fe06 100644 (file)
@@ -319,6 +319,7 @@ SSMRESULT CQueryEngine::executeContextQuery(std::string contextQuery, int *cqid)
     pConditionedQuery->addRef();
     m_conditionedQueries[m_cqid] = pConditionedQuery;
     m_contextQueries[m_cqid] = clsContextQuery;
+    clsContextQuery = NULL; //Mark it NULL, so that it's not freed in CLEANUP.
     m_mtxQueries.unlock();
 
     if (pConditionedQuery->hasAllConditionedModels() == true)
@@ -367,6 +368,7 @@ SSMRESULT CQueryEngine::executeContextQuery(std::string contextQuery, int *cqid)
 CLEANUP:
     SAFE_RELEASE(pConditionedQuery);
     SAFE_RELEASE(pConditionedQueryResult);
+    SAFE_DELETE(clsContextQuery);
     return res;
 }