diff options
| author | 2017-03-05 18:45:59 -0500 | |
|---|---|---|
| committer | 2017-03-05 18:45:59 -0500 | |
| commit | 638ef7834ef13594adad25923355d71a019e4f22 (patch) | |
| tree | 4750e8e9b73b1eb448fe5d012f362946aa1648c8 /src/modules/window/libkviwindow.cpp | |
| parent | Fix various memory leaks in usages of static KviKvsScript::run (diff) | |
| download | KVIrc-638ef7834ef13594adad25923355d71a019e4f22.tar.gz KVIrc-638ef7834ef13594adad25923355d71a019e4f22.tar.bz2 KVIrc-638ef7834ef13594adad25923355d71a019e4f22.zip | |
module window: Fix memory leak in crypt engine initializer.
Diffstat (limited to 'src/modules/window/libkviwindow.cpp')
| -rw-r--r-- | src/modules/window/libkviwindow.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/modules/window/libkviwindow.cpp b/src/modules/window/libkviwindow.cpp index 9785b366a..30baddb9e 100644 --- a/src/modules/window/libkviwindow.cpp +++ b/src/modules/window/libkviwindow.cpp @@ -1389,10 +1389,9 @@ static bool window_kvs_cmd_savePropertiesAsDefault(KviKvsModuleCommandCall * c) static bool initializeCryptEngine(KviCryptEngine * eng, KviCString & szEncryptKey, KviCString & szDecryptKey, QString & szError) { char * encKey = nullptr; - int encKeyLen = 0; char * tmpKey; - encKeyLen = szEncryptKey.hexToBuffer(&tmpKey, false); + int encKeyLen = szEncryptKey.hexToBuffer(&tmpKey, false); if(encKeyLen > 0) { encKey = (char *)KviMemory::allocate(encKeyLen); @@ -1406,9 +1405,8 @@ static bool initializeCryptEngine(KviCryptEngine * eng, KviCString & szEncryptKe } char * decKey = nullptr; - int decKeyLen = 0; - decKeyLen = szDecryptKey.hexToBuffer(&tmpKey, false); + int decKeyLen = szDecryptKey.hexToBuffer(&tmpKey, false); if(decKeyLen > 0) { decKey = (char *)KviMemory::allocate(decKeyLen); @@ -1418,6 +1416,8 @@ static bool initializeCryptEngine(KviCryptEngine * eng, KviCString & szEncryptKe else { szError = __tr2qs("The decryption key wasn't a valid hexadecimal string"); + if(encKey) + KviMemory::free(encKey); return false; } bool bRet = eng->init(encKey, encKeyLen, decKey, decKeyLen); |
