modify ipcbuffer to remove memory leak
authorso.yu <so.yu@samsung.com>
Mon, 22 Jul 2013 11:45:36 +0000 (20:45 +0900)
committerso.yu <so.yu@samsung.com>
Mon, 22 Jul 2013 11:48:25 +0000 (20:48 +0900)
Change-Id: Ib581641cbd99e2268242d4a073bd0bd411a68ec1
Signed-off-by: so.yu <so.yu@samsung.com>
src/security/cert/FSecCert_CertServiceProxy.cpp
src/security/inc/FSecCert_CertMgrMessages.h

index 72aed1d..56f5ca1 100755 (executable)
@@ -174,7 +174,7 @@ _CertServiceProxy::GetNextCertificate(int certType, int& curPos, byte* pBuffer,
        result r = E_SUCCESS;
        result ret = E_SUCCESS;
 
-       Tizen::Io::_IpcBuffer certBufferIpc;
+       Tizen::Base::ByteBuffer certBufferIpc;
 
        ClearLastResult();
 
@@ -183,9 +183,6 @@ _CertServiceProxy::GetNextCertificate(int certType, int& curPos, byte* pBuffer,
        SysTryReturnResult(NID_SEC_CERT, certType > _CERT_TYPE_NOT_BOUNDED, E_INVALID_ARG, "Invalid certificate type.");
        SysTryReturnResult(NID_SEC_CERT, certType < _CERT_TYPE_MAX, E_INVALID_ARG, "Invalid certificate type.");
 
-       certBufferIpc.pBuffer = null;
-       certBufferIpc.size = 0;
-
        std::unique_ptr< IPC::Message > pMessage(new (std::nothrow) CertServer_GetNextCertificate(certType, curPos, bufferLen, &certBufferIpc, &curPos, &ret));
        SysTryReturnResult(NID_SEC_CERT, pMessage != null, E_OUT_OF_MEMORY, "Failed to allocate memory.");
 
@@ -193,8 +190,8 @@ _CertServiceProxy::GetNextCertificate(int certType, int& curPos, byte* pBuffer,
        SysTryReturn(NID_SEC_CERT, !IsFailed(r), r, r, "[%s] Failed to send message.", GetErrorMessage(r));
        SysTryReturn(NID_SEC_CERT, !IsFailed(ret), ret, ret, "[%s] Stub function failed on service side.", GetErrorMessage(ret));
 
-       memcpy(pBuffer, certBufferIpc.pBuffer, certBufferIpc.size);
-       bufferLen = certBufferIpc.size;
+       memcpy(pBuffer, certBufferIpc.GetPointer(), certBufferIpc.GetRemaining());
+       bufferLen = certBufferIpc.GetRemaining();
 
        return r;
 }
index da207ec..ac07642 100755 (executable)
@@ -288,7 +288,7 @@ IPC_SYNC_MESSAGE_CONTROL0_1(CertServer_GetName, result);
 IPC_SYNC_MESSAGE_CONTROL1_1(CertServer_CloseCertificateStore, int, result);
 IPC_SYNC_MESSAGE_CONTROL1_2(CertServer_OpenCertificateStoreByType, int, int, result);
 IPC_SYNC_MESSAGE_CONTROL1_2(CertServer_GetCertificateCount, int, int, result);
-IPC_SYNC_MESSAGE_CONTROL3_3(CertServer_GetNextCertificate, int, int, int, Tizen::Io::_IpcBuffer,int , result);
+IPC_SYNC_MESSAGE_CONTROL3_3(CertServer_GetNextCertificate, int, int, int, Tizen::Base::ByteBuffer, int , result);
 IPC_SYNC_MESSAGE_CONTROL3_1(CertServer_InsertRootCa, int, Tizen::Io::_IpcBuffer, int, result);
 IPC_SYNC_MESSAGE_CONTROL3_1(CertServer_UpdateRootCa, int, Tizen::Io::_IpcBuffer, Tizen::Io::_IpcBuffer, result);
 IPC_SYNC_MESSAGE_CONTROL3_1(CertServer_RemoveRootCa, int, Tizen::Io::_IpcBuffer, int, result);