From 046f31c718fbdeb3bc5d625990d83e0e010491eb Mon Sep 17 00:00:00 2001 From: "hb.min" Date: Mon, 15 Jul 2013 14:05:09 +0900 Subject: [PATCH] Fix memory leaks Change-Id: I1ce36d12c8abac5605c418b8ce83763aad5bc401 Signed-off-by: hb.min --- src/security/FSec_PrivacyInfoImpl.cpp | 7 ++++++- src/security/FSec_PrivilegeInfo.cpp | 2 +- src/security/FSec_PrivilegeManager.cpp | 10 ++++++++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/security/FSec_PrivacyInfoImpl.cpp b/src/security/FSec_PrivacyInfoImpl.cpp index 941ac9c..d436b14 100755 --- a/src/security/FSec_PrivacyInfoImpl.cpp +++ b/src/security/FSec_PrivacyInfoImpl.cpp @@ -90,8 +90,13 @@ _PrivacyInfoImpl::GetDisplayName(void) const privacyInfo.privacy_id = pPrivacyId.get(); ret = privacy_info_client_get_privacy_display_name(&privacyInfo, &pPrivacyDisplayName); SysTryReturn(NID_SEC, ret == PRIV_MGR_ERROR_SUCCESS, displayName, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred."); - displayName.Append(pPrivacyDisplayName); + + if (pPrivacyDisplayName != null) + { + free(pPrivacyDisplayName); + } + return displayName; } diff --git a/src/security/FSec_PrivilegeInfo.cpp b/src/security/FSec_PrivilegeInfo.cpp index 53e6fac..1cb7d72 100644 --- a/src/security/FSec_PrivilegeInfo.cpp +++ b/src/security/FSec_PrivilegeInfo.cpp @@ -593,7 +593,7 @@ _PrivilegeInfo::VerifyIntegrity(const AppId& appId, const byte* targetBitwisePri ByteBuffer input; std::unique_ptr pHash(null); std::unique_ptr pChecksumByteBuffer(null); - std::unique_ptr pAppId(null); + std::unique_ptr pAppId(null); SysTryReturnResult(NID_SEC, length <= MAX_BITWISE_PRIV_SIZE, E_INVALID_ARG, "The privilege information of %ls is invalid.", appId.GetPointer()); diff --git a/src/security/FSec_PrivilegeManager.cpp b/src/security/FSec_PrivilegeManager.cpp index d6ce9ec..441e44c 100644 --- a/src/security/FSec_PrivilegeManager.cpp +++ b/src/security/FSec_PrivilegeManager.cpp @@ -191,7 +191,10 @@ _PrivilegeManager::RetrieveCipherPrivilegeN(const AppId& appId, Tizen::Base::Str pPrivilegeList = new ArrayList; r = pPrivilegeList->Construct(); - IEnumerator* pEnum = tempPrivilegeList.GetEnumeratorN(); + std::unique_ptr pEnum(null); + pEnum.reset(tempPrivilegeList.GetEnumeratorN()); + SysTryReturnResult(NID_SEC, pEnum != null, E_SYSTEM, "An unexpected system error occurred."); + while (pEnum->MoveNext() == E_SUCCESS) { String* tempString = static_cast< String* >(pEnum->GetCurrent()); @@ -245,7 +248,10 @@ _PrivilegeManager::RetrieveCipherPrivilegeExN(const AppId& appId, Tizen::Base::S pPrivilegeList = new ArrayList; r = pPrivilegeList->Construct(); - IEnumerator* pEnum = tempPrivilegeList.GetEnumeratorN(); + std::unique_ptr pEnum(null); + pEnum.reset(tempPrivilegeList.GetEnumeratorN()); + SysTryReturnResult(NID_SEC, pEnum != null, E_SYSTEM, "An unexpected system error occurred."); + while (pEnum->MoveNext() == E_SUCCESS) { String* tempString = static_cast< String* >(pEnum->GetCurrent()); -- 2.7.4