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