From fd0e7a1e1c938096b5a9c9bffad248d2cd805c61 Mon Sep 17 00:00:00 2001 From: Anju Date: Mon, 15 Jul 2013 16:55:18 +0530 Subject: [PATCH] [SECURITY] Fixed valgrind tool issues Change-Id: Iaadef926676173b19c0812cb473caffae7aa63b1 Signed-off-by: Anju --- src/security/pkcs/FSecPkcs_Pkcs08AttributeImpl.cpp | 2 ++ src/security/pkcs/FSecPkcs_Pkcs08EncryptedPrivateKeyInfoImpl.cpp | 5 ++++- src/security/pkcs/FSecPkcs_Pkcs08PrivateKeyInfoImpl.cpp | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/security/pkcs/FSecPkcs_Pkcs08AttributeImpl.cpp b/src/security/pkcs/FSecPkcs_Pkcs08AttributeImpl.cpp index 5234ef7..e796141 100644 --- a/src/security/pkcs/FSecPkcs_Pkcs08AttributeImpl.cpp +++ b/src/security/pkcs/FSecPkcs_Pkcs08AttributeImpl.cpp @@ -50,6 +50,8 @@ _Pkcs08AttributeImpl::_Pkcs08AttributeImpl(void) _Pkcs08AttributeImpl::~_Pkcs08AttributeImpl(void) { + if (__attributeValues.GetCount() > 0) + __attributeValues.RemoveAll(); //do nothing } diff --git a/src/security/pkcs/FSecPkcs_Pkcs08EncryptedPrivateKeyInfoImpl.cpp b/src/security/pkcs/FSecPkcs_Pkcs08EncryptedPrivateKeyInfoImpl.cpp index 9a28344..c4c68fc 100644 --- a/src/security/pkcs/FSecPkcs_Pkcs08EncryptedPrivateKeyInfoImpl.cpp +++ b/src/security/pkcs/FSecPkcs_Pkcs08EncryptedPrivateKeyInfoImpl.cpp @@ -139,7 +139,10 @@ _Pkcs08EncryptedPrivateKeyInfoImpl::Construct(const AlgorithmIdentifier& algorit SysTryReturn(NID_SEC_CRYPTO, encryptedData.GetRemaining() > 0, r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] The specified input parameter is invalid."); - r = __encryptionAlgorithm.Construct(algorithmId.GetAlgorithmObjectId(), algorithmId.GetParametersN()); + std::unique_ptr< IAlgorithmParameters > pParam(algorithmId.GetParametersN()); + SysTryReturn(NID_SEC_CRYPTO, pParam != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] The memory is insufficient."); + + r = __encryptionAlgorithm.Construct(algorithmId.GetAlgorithmObjectId(), pParam.get()); SysTryReturn(NID_SEC_CRYPTO, !IsFailed(r), r, r, "[%s] Failed to construct the algorithm identifier instance for encryption algorithm.", GetErrorMessage(r)); r = __encryptedData.Construct(encryptedData); diff --git a/src/security/pkcs/FSecPkcs_Pkcs08PrivateKeyInfoImpl.cpp b/src/security/pkcs/FSecPkcs_Pkcs08PrivateKeyInfoImpl.cpp index 8f2ae40..3fff4e1 100644 --- a/src/security/pkcs/FSecPkcs_Pkcs08PrivateKeyInfoImpl.cpp +++ b/src/security/pkcs/FSecPkcs_Pkcs08PrivateKeyInfoImpl.cpp @@ -54,6 +54,8 @@ _Pkcs08PrivateKeyInfoImpl::_Pkcs08PrivateKeyInfoImpl(void) //Default Destructor _Pkcs08PrivateKeyInfoImpl::~_Pkcs08PrivateKeyInfoImpl(void) { + if (__attributes.GetCount() > 0) + __attributes.RemoveAll(); //do nothing } -- 2.7.4