summaryrefslogtreecommitdiff
path: root/plugins/CryptoPP/src/cpp_pgpw.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-10-22 19:30:48 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-10-22 19:30:48 +0000
commit4164b967c13c87fd2a5a3459b037a6a823faa872 (patch)
tree873ff8f5ba9900c06a444c4b0d2e46651c1eaf37 /plugins/CryptoPP/src/cpp_pgpw.cpp
parent5a6789f0c45660feb1dbd5ada8438c43b8f6bb2c (diff)
SecureIM:
- fixed crash with memory allocation conflict; - version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@6593 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/CryptoPP/src/cpp_pgpw.cpp')
-rw-r--r--plugins/CryptoPP/src/cpp_pgpw.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/plugins/CryptoPP/src/cpp_pgpw.cpp b/plugins/CryptoPP/src/cpp_pgpw.cpp
index 84349583c7..96a6baece4 100644
--- a/plugins/CryptoPP/src/cpp_pgpw.cpp
+++ b/plugins/CryptoPP/src/cpp_pgpw.cpp
@@ -145,16 +145,18 @@ LPSTR __cdecl pgp_encrypt(pCNTX ptr, LPCSTR szPlainMsg)
{
ptr->error = ERROR_NONE;
pPGPDATA p = (pPGPDATA) ptr->pdata;
- SAFE_FREE(ptr->tmp);
LPSTR szEncMsg;
if (p->pgpKey)
szEncMsg = p_pgp_encrypt_key(szPlainMsg,(LPCSTR)p->pgpKey);
else
szEncMsg = p_pgp_encrypt_keydb(szPlainMsg,p->pgpKeyID);
- if (!szEncMsg) return 0;
+ if (!szEncMsg) {
+ replaceStr(ptr->tmp, NULL);
+ return 0;
+ }
- ptr->tmp = (LPSTR) _strdup(szEncMsg);
+ replaceStr(ptr->tmp, mir_strdup(szEncMsg));
LocalFree((LPVOID)szEncMsg);
return ptr->tmp;
@@ -164,7 +166,6 @@ LPSTR __cdecl pgp_encrypt(pCNTX ptr, LPCSTR szPlainMsg)
LPSTR __cdecl pgp_decrypt(pCNTX ptr, LPCSTR szEncMsg)
{
ptr->error = ERROR_NONE;
- SAFE_FREE(ptr->tmp);
LPSTR szPlainMsg = p_pgp_decrypt_keydb(szEncMsg);
if (!szPlainMsg) {
@@ -174,12 +175,14 @@ LPSTR __cdecl pgp_decrypt(pCNTX ptr, LPCSTR szEncMsg)
if (p->pgpKey)
szPlainMsg = p_pgp_decrypt_key(szEncMsg,(LPCSTR)p->pgpKey);
}
- if (!szPlainMsg) return NULL;
+ if (!szPlainMsg) {
+ replaceStr(ptr->tmp, NULL);
+ return NULL;
+ }
}
- ptr->tmp = (LPSTR) _strdup(szPlainMsg);
+ replaceStr(ptr->tmp, mir_strdup(szPlainMsg));
LocalFree((LPVOID)szPlainMsg);
-
return ptr->tmp;
}
@@ -215,8 +218,7 @@ LPSTR __cdecl pgp_decode(HANDLE context, LPCSTR szEncMsg)
}
else szNewMsg = _strdup(szOldMsg);
}
- SAFE_FREE(ptr->tmp);
- ptr->tmp = szNewMsg;
+ replaceStr(ptr->tmp, szNewMsg);
return szNewMsg;
}