summaryrefslogtreecommitdiff
path: root/plugins/CryptoPP/src/cpp_gpgw.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_gpgw.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_gpgw.cpp')
-rw-r--r--plugins/CryptoPP/src/cpp_gpgw.cpp24
1 files changed, 8 insertions, 16 deletions
diff --git a/plugins/CryptoPP/src/cpp_gpgw.cpp b/plugins/CryptoPP/src/cpp_gpgw.cpp
index ff62e0104d..3336b825df 100644
--- a/plugins/CryptoPP/src/cpp_gpgw.cpp
+++ b/plugins/CryptoPP/src/cpp_gpgw.cpp
@@ -68,17 +68,18 @@ LPSTR __cdecl gpg_get_error()
LPSTR __cdecl gpg_encrypt(pCNTX ptr, LPCSTR szPlainMsg)
{
- ptr->error = ERROR_NONE;
+ ptr->error = ERROR_NONE;
pGPGDATA p = (pGPGDATA) ptr->pdata;
- SAFE_FREE(ptr->tmp);
LPSTR szEncMsg;
szEncMsg = _gpg_encrypt(szPlainMsg,(LPCSTR)p->gpgKeyID);
- if (!szEncMsg) return 0;
+ if (!szEncMsg) {
+ replaceStr(ptr->tmp, 0);
+ return 0;
+ }
- ptr->tmp = (LPSTR)_strdup(szEncMsg);
+ replaceStr(ptr->tmp, mir_strdup(szEncMsg));
LocalFree((LPVOID)szEncMsg);
-
return ptr->tmp;
}
@@ -86,17 +87,9 @@ LPSTR __cdecl gpg_encrypt(pCNTX ptr, LPCSTR szPlainMsg)
LPSTR __cdecl gpg_decrypt(pCNTX ptr, LPCSTR szEncMsg)
{
ptr->error = ERROR_NONE;
- SAFE_FREE(ptr->tmp);
LPSTR szPlainMsg = _gpg_decrypt(szEncMsg);
-/* if (!szPlainMsg) {
- ptr = get_context_on_id(hPGPPRIV); // find private pgp keys
- if (ptr && ptr->pgpKey)
- szPlainMsg = _gpg_decrypt_key(szEncMsg,(LPCSTR)ptr->pgpKey);
- if (!szPlainMsg) return NULL;
- }*/
-
- ptr->tmp = (LPSTR)_strdup(szPlainMsg);
+ replaceStr(ptr->tmp, mir_strdup(szPlainMsg));
LocalFree((LPVOID)szPlainMsg);
return ptr->tmp;
@@ -143,8 +136,7 @@ LPSTR __cdecl gpg_decode(HANDLE context, LPCSTR szEncMsg)
szNewMsg = _strdup(szOldMsg);
}
}
- SAFE_FREE(ptr->tmp);
- ptr->tmp = szNewMsg;
+ replaceStr(ptr->tmp, szNewMsg);
return szNewMsg;
}