From 29eb1dcfe65cf2c97d5d7dc27e5bc303643cef1e Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Wed, 22 Aug 2018 13:22:37 -0400 Subject: [PATCH] fix memory leaks --- GUI/extensions.cpp | 2 +- extensions/googletranslate.cpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/GUI/extensions.cpp b/GUI/extensions.cpp index 4a5d66f..95a206a 100644 --- a/GUI/extensions.cpp +++ b/GUI/extensions.cpp @@ -33,7 +33,7 @@ std::wstring DispatchSentenceToExtensions(std::wstring sentence, std::unordered_ wcscpy(sentenceBuffer, sentence.c_str()); InfoForExtension* miscInfoLinkedList = new InfoForExtension; InfoForExtension* miscInfoTraverser = miscInfoLinkedList; - for (auto& i : miscInfo) miscInfoTraverser = miscInfoTraverser->nextProperty = new InfoForExtension{ i.first.c_str(), i.second, new InfoForExtension }; + for (auto& i : miscInfo) miscInfoTraverser = miscInfoTraverser->nextProperty = new InfoForExtension{ i.first.c_str(), i.second, nullptr }; extenMutex.lock_shared(); for (auto i : extensions) { diff --git a/extensions/googletranslate.cpp b/extensions/googletranslate.cpp index d748ac4..df5415b 100644 --- a/extensions/googletranslate.cpp +++ b/extensions/googletranslate.cpp @@ -25,6 +25,7 @@ std::wstring GetTranslationUri(const wchar_t* text, unsigned int TKK) a %= 1000000; b ^= a; + delete[] utf8text; return std::wstring(L"/translate_a/single?client=t&dt=ld&dt=rm&dt=t&tk=") + std::to_wstring(a) + L"." + std::to_wstring(b) + L"&q=" + std::wstring(text); }