From b46227977f41f508baec3f6a059688cb08b742b7 Mon Sep 17 00:00:00 2001 From: Woowon Date: Tue, 23 Apr 2013 14:24:55 +0900 Subject: [PATCH] Fix memory leak Change-Id: Iacd3e518234a33949ba3cc312086dbf5d197ebe8 Signed-off-by: Woowon --- src/FNetNfc_NfcManagerImpl.cpp | 37 +++++++++++++++++++++++++++++++++++++ src/FNetNfc_TagConnectionImpl.cpp | 1 + 2 files changed, 38 insertions(+) diff --git a/src/FNetNfc_NfcManagerImpl.cpp b/src/FNetNfc_NfcManagerImpl.cpp index e8527cd..e8533d1 100644 --- a/src/FNetNfc_NfcManagerImpl.cpp +++ b/src/FNetNfc_NfcManagerImpl.cpp @@ -86,8 +86,45 @@ _NfcManagerImpl::~_NfcManagerImpl(void) delete __pCurrentTagImpl; delete __pMgrEvent; + + unique_ptr pTagConditionList(__pTagConditionMap->GetValuesN()); + unique_ptr pTagConditionEnum(pTagConditionList->GetEnumeratorN()); + while (pTagConditionEnum->MoveNext() == E_SUCCESS) + { + _NfcTagEventMap* pEventMap = dynamic_cast <_NfcTagEventMap*> (pTagConditionEnum->GetCurrent()); + if (pEventMap) + { + unique_ptr > pEventList(pEventMap->GetValuesN()); + unique_ptr > pEventEnum(pEventList->GetEnumeratorN()); + while (pEventEnum->MoveNext() == E_SUCCESS) + { + _NfcTagDiscoveryEvent* pEvent = null; + pEventEnum->GetCurrent(pEvent); + delete pEvent; + } + } + } delete __pTagConditionMap; + + unique_ptr pNdefConditionList(__pNdefConditionMap->GetValuesN()); + unique_ptr pNdefConditionEnum(pNdefConditionList->GetEnumeratorN()); + while (pNdefConditionEnum->MoveNext() == E_SUCCESS) + { + _NdefMsgEventMap* pEventMap = dynamic_cast <_NdefMsgEventMap*> (pNdefConditionEnum->GetCurrent()); + if (pEventMap) + { + unique_ptr > pEventList(pEventMap->GetValuesN()); + unique_ptr > pEventEnum(pEventList->GetEnumeratorN()); + while (pEventEnum->MoveNext() == E_SUCCESS) + { + _NdefMessageDiscoveryEvent* pEvent = null; + pEventEnum->GetCurrent(pEvent); + delete pEvent; + } + } + } delete __pNdefConditionMap; + delete __pDeviceDiscoveryEvent; } diff --git a/src/FNetNfc_TagConnectionImpl.cpp b/src/FNetNfc_TagConnectionImpl.cpp index b5c5bf8..cd48649 100644 --- a/src/FNetNfc_TagConnectionImpl.cpp +++ b/src/FNetNfc_TagConnectionImpl.cpp @@ -61,6 +61,7 @@ _TagConnectionImpl::~_TagConnectionImpl(void) } delete __pTargetTag; + delete __pConnEvent; } result -- 2.7.4