From 638ef7834ef13594adad25923355d71a019e4f22 Mon Sep 17 00:00:00 2001 From: IceN9ne Date: Sun, 5 Mar 2017 18:45:59 -0500 Subject: module window: Fix memory leak in crypt engine initializer. --- src/modules/window/libkviwindow.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/modules/window/libkviwindow.cpp') 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); -- cgit v1.3.1-10-gc9f91