B
bhavya internship
Guest
Hello All,
When using the CAutoPtr I am getting the below warning message:
delete_var: ~CAutoPtr uses delete on pwszBuffer.m_p which is an array. It should be deleted with operator delete[]
As far as I know, there is no need to explicitly call delete when using CAutoPtr
Could anyone please help me?
Below is my code snippet:
bool EMRReader::EncodeBase64(DWORD dwSize, const string& strData, wstring& sBase64)
{
DWORD dwOptions = CRYPT_STRING_BASE64 | CRYPT_STRING_NOCRLF;
DWORD dwLength = 0;
BOOL bRet = CryptBinaryToString(reinterpret_cast<const BYTE*>(strData.c_str()), dwSize,
dwOptions, 0, &dwLength);
if (!bRet)
return bRet;
CAutoPtr<wchar_t> pwszBuffer(new (std::nothrow) wchar_t[dwLength + 1]);
if (!pwszBuffer)
return FALSE;
SecureZeroMemory((wchar_t *)pwszBuffer, (dwLength + 1) * sizeof(wchar_t));
CryptBinaryToString(reinterpret_cast<const BYTE*>(strData.c_str()), dwSize,
dwOptions, pwszBuffer, &dwLength);
sBase64 = pwszBuffer;
return TRUE;
}
Regards,
Continue reading...
When using the CAutoPtr I am getting the below warning message:
delete_var: ~CAutoPtr uses delete on pwszBuffer.m_p which is an array. It should be deleted with operator delete[]
As far as I know, there is no need to explicitly call delete when using CAutoPtr
Could anyone please help me?
Below is my code snippet:
bool EMRReader::EncodeBase64(DWORD dwSize, const string& strData, wstring& sBase64)
{
DWORD dwOptions = CRYPT_STRING_BASE64 | CRYPT_STRING_NOCRLF;
DWORD dwLength = 0;
BOOL bRet = CryptBinaryToString(reinterpret_cast<const BYTE*>(strData.c_str()), dwSize,
dwOptions, 0, &dwLength);
if (!bRet)
return bRet;
CAutoPtr<wchar_t> pwszBuffer(new (std::nothrow) wchar_t[dwLength + 1]);
if (!pwszBuffer)
return FALSE;
SecureZeroMemory((wchar_t *)pwszBuffer, (dwLength + 1) * sizeof(wchar_t));
CryptBinaryToString(reinterpret_cast<const BYTE*>(strData.c_str()), dwSize,
dwOptions, pwszBuffer, &dwLength);
sBase64 = pwszBuffer;
return TRUE;
}
Regards,
Continue reading...