prevent issue fixes
authorKarthik Subas Chandra Bose <karthik.scb@samsung.com>
Tue, 24 Sep 2013 02:48:13 +0000 (11:48 +0900)
committerKarthik Subas Chandra Bose <karthik.scb@samsung.com>
Tue, 24 Sep 2013 03:08:43 +0000 (12:08 +0900)
Change-Id: I2d7d7c05617fbdfafa02f1611845d0ef8740be32
Signed-off-by: Karthik Subas Chandra Bose <karthik.scb@samsung.com>
src/FApp_ConditionManagerService.cpp

index 219b0ff..1960d24 100644 (file)
@@ -120,7 +120,7 @@ _ConditionManagerService::InitializePluginData(void)
 
        r = reg.GetSectionListN(&pSections);
        SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to GetSectionListN.");
-        SysTryReturnResult(NID_APP, pSections != null, r, "Condition plugin info does not exist.");
+       SysTryReturnResult(NID_APP, pSections != null, r, "Condition plugin info does not exist.");
 
        std::unique_ptr<IEnumerator> pEnum(pSections->GetEnumeratorN());
        SysTryCatch(NID_APP, pEnum != null,  , E_FAILURE, "failed to GetEnumeratorN.");
@@ -251,7 +251,7 @@ _ConditionManagerService::InitializeConditionalOperations(void)
 
                r = _ConditionDatabaseHelper::GetAllSectionsFromConditionDb(pSections.get());
                SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to GetAllSectionsFromConditionDb.");
-                SysTryReturnResult(NID_APP, pSections != null, r, "App Launch conditions does not exist.");
+               SysTryReturnResult(NID_APP, pSections != null, r, "App Launch conditions does not exist.");
 
                std::unique_ptr< IEnumerator > pEnum(pSections->GetEnumeratorN());
                SysTryReturnResult(NID_APP, pEnum != null, r, "failed to GetEnumeratorN.");
@@ -514,6 +514,7 @@ _ConditionDatabaseHelper::InsertRecordToConditionDb(const String& sectionName, c
                const String& condition, const IList* pArgs)
 {
        _DatabaseImpl condDb;
+       DbEnumerator* pEnum = null;
        void* pBundleBuf = null;
        int length = 0;
        String statement;
@@ -559,23 +560,34 @@ _ConditionDatabaseHelper::InsertRecordToConditionDb(const String& sectionName, c
                SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to ConvertArgToBundleN.");
 
                r = pStmt->BindInt(DB_TABLE_COND_ARG_COUNT, pArgs->GetCount());
-               SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to bind argcount to database.");
+               SysTryCatch(NID_APP, !IsFailed(r),  , r, "failed to bind argcount to database.");
 
                r = pStmt->BindInt(DB_TABLE_COND_ARG_LENGTH, length);
-               SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to bind length to database.");
+               SysTryCatch(NID_APP, !IsFailed(r),  , r, "failed to bind length to database.");
 
                r = pStmt->BindBlob(DB_TABLE_COND_ARG, pBundleBuf, length);
-               SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to bind pBundleBuf to database.");
+               SysTryCatch(NID_APP, !IsFailed(r),  , r, "failed to bind pBundleBuf to database.");
        }
 
-       std::unique_ptr<DbEnumerator> pEnum(condDb.ExecuteStatementN(*pStmt));
-       SysTryReturnResult(NID_APP, pEnum == null, r, "pEnum should be null as INSERT operation took place.");
+       pEnum = condDb.ExecuteStatementN(*pStmt);
+       SysTryCatch(NID_APP, pEnum == null,  , r, "pEnum should be null as INSERT operation took place.");
 
        r = condDb.CommitTransaction();
-       SysTryReturnResult(NID_APP, !IsFailed(r), r, "failed to commit database transaction.");
+       SysTryCatch(NID_APP, !IsFailed(r),  , r, "failed to commit database transaction.");
 
-       bundle_free_encoded_rawdata((bundle_raw**)&pBundleBuf);
+       if(pBundleBuf != null)
+       {
+               bundle_free_encoded_rawdata((bundle_raw**)&pBundleBuf);
+       }
        return E_SUCCESS;
+
+CATCH:
+       SysLog(NID_APP, "Catch.");
+       if(pBundleBuf != null)
+       {
+               bundle_free_encoded_rawdata((bundle_raw**)&pBundleBuf);
+               return r;
+       }
 }
 
 result
@@ -725,8 +737,8 @@ _ConditionDatabaseHelper::ConvertArgToBundleN(const String& key, const IList* pA
                char* pValue = _StringConverter::CopyToCharArrayN(*pStr);
 
                bunRet = bundle_add(pBundle, pKey, pValue);
-               delete pKey;
-               delete pValue;
+               delete[] pKey;
+               delete[] pValue;
        }
 
        bunRet = bundle_encode_raw(pBundle, &pBundleRaw, &length);
@@ -762,7 +774,7 @@ _ConditionDatabaseHelper::ConvertBundleToArgN(const String& key, void*& pBundleB
                {
                        pArgs->Add(*(new (std::nothrow) String(pValue)));
                }
-               delete pKey;
+               delete[] pKey;
        }
 
        free(pBundleBuf);