Fix GetPrivilegeListN() API
authorDuyoung Jang <duyoung.jang@samsung.com>
Thu, 18 Apr 2013 13:41:46 +0000 (22:41 +0900)
committerDuyoung Jang <duyoung.jang@samsung.com>
Thu, 18 Apr 2013 13:41:46 +0000 (22:41 +0900)
Change-Id: I71528d5dd0b7545ef051c7800cf51f81faff5ec2
Signed-off-by: Duyoung Jang <duyoung.jang@samsung.com>
src/app/package/FAppPkg_PackageInfoImpl.cpp

index 4750878..ae76365 100755 (executable)
@@ -468,25 +468,33 @@ _PackageInfoImpl::GetPrivilegeListN(void) const
 
        result r = E_SUCCESS;
 
-       ArrayList* pPrivilegeList = new (std::nothrow) ArrayList;
+       std::unique_ptr< ArrayList > pPrivilegeList(new (std::nothrow) ArrayList);
        SysTryReturn(NID_APP, pPrivilegeList, null, E_OUT_OF_MEMORY, "pPrivilegeList must not be null.");
        pPrivilegeList->Construct();
 
        for (int i = 0; i < __pPrivilegeList->GetCount(); i++)
        {
-               String* pPrivilege = dynamic_cast <String*>(__pPrivilegeList->GetAt(i));
+               String* pPrivilege = dynamic_cast < String* >(__pPrivilegeList->GetAt(i));
                if (pPrivilege)
                {
-                       PrivilegeInfo* pPrivilegeInfo = new (std::nothrow) PrivilegeInfo;
+                       std::unique_ptr< PrivilegeInfo > pPrivilegeInfo(new (std::nothrow) PrivilegeInfo);
                        SysTryReturn(NID_APP, pPrivilegeInfo, null, E_OUT_OF_MEMORY, "pPrivilegeInfo must not be null.");
 
-                       pPrivilegeInfo->Construct(*pPrivilege);
+                       r = pPrivilegeInfo->Construct(*pPrivilege);
+                       SysTryReturn(NID_APP, !IsFailed(r), null, E_SYSTEM, "pPrivilegeInfo->Construct() failed.");
 
-                       r = pPrivilegeList->Add(*pPrivilegeInfo);
+                       r = pPrivilegeList->Add(*pPrivilegeInfo.release());
+                       SysTryReturn(NID_APP, !IsFailed(r), null, E_SYSTEM, "pPrivilegeList->Add() failed.");
                }
         }
 
-       return pPrivilegeList;
+       if (pPrivilegeList->GetCount() <= 0)
+       {
+               SysLog(NID_APP, "pPrivilegeList->GetCount() is invalid.");
+               return null;
+       }
+
+       return pPrivilegeList.release();
 }
 
 result