Fix prevent defect
authorhb.min <hb.min@samsung.com>
Thu, 13 Jun 2013 03:58:59 +0000 (12:58 +0900)
committerhb.min <hb.min@samsung.com>
Thu, 13 Jun 2013 03:58:59 +0000 (12:58 +0900)
Change-Id: I2d8a7ace3a999b7b171c62cc58373a5edd2c911f
Signed-off-by: hb.min <hb.min@samsung.com>
src/server/security/FSec_PrivilegeManagerServer.cpp

index 4fcfd45..b6fcecc 100644 (file)
@@ -196,17 +196,14 @@ _PrivilegeManagerServer::GetChecksum(AppId appId, int visibility, String& checks
        ByteBuffer input;
        IHmac* pHmac = null;
        ByteBuffer* pChecksumByteBuffer = null;
-       char* pAppId = null;
 
-       pAppId = (char*) _StringConverter::CopyToCharArrayN(appId);
+       std::unique_ptr<char[]> pAppId(null);
+       pAppId.reset(_StringConverter::CopyToCharArrayN(appId));
        SysTryCatch(NID_SEC, pAppId != null, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");
 
-       memcpy(tempChecksumString, pAppId, MAX_APP_ID_SIZE);
+       memcpy(tempChecksumString, pAppId.get(), MAX_APP_ID_SIZE);
        memcpy(tempChecksumString + MAX_APP_ID_SIZE, (byte*)(&visibility), sizeof(int));
 
-       delete[] pAppId;
-       pAppId = null;
-
        r = input.Construct(MAX_APP_ID_SIZE + sizeof(int));
        SysTryCatch(NID_SEC, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] An unexpected system error occurred.");