From a12898911c304805ffc26b6dcf4583b3ac65a036 Mon Sep 17 00:00:00 2001
From: George Hazan <ghazan@miranda.im>
Date: Fri, 27 Jul 2018 15:41:33 +0300
Subject: fix for occasional crash in StopSpam

---
 plugins/StopSpamPlus/src/events.cpp  | 6 ++----
 plugins/StopSpamPlus/src/options.cpp | 6 +++---
 2 files changed, 5 insertions(+), 7 deletions(-)

(limited to 'plugins/StopSpamPlus')

diff --git a/plugins/StopSpamPlus/src/events.cpp b/plugins/StopSpamPlus/src/events.cpp
index b56e108d9b..e5875f9407 100644
--- a/plugins/StopSpamPlus/src/events.cpp
+++ b/plugins/StopSpamPlus/src/events.cpp
@@ -28,15 +28,13 @@ int OnDbEventAdded(WPARAM, LPARAM lParam)
 		//and if I don't sent message to this contact
 		if (db_get_b(hcntct, "CList", "NotOnList", 0) && !db_get_b(hcntct, MODULENAME, answeredSetting, 0) && !IsExistMyMessage(hcntct)) {
 			if (!g_sets.HandleAuthReq) {
-				char *buf = mir_utf8encodeW(variables_parse(g_sets.AuthRepl, hcntct).c_str());
+				char *buf = mir_utf8encodeW(variables_parse(g_sets.getReply(), hcntct).c_str());
 				ProtoChainSend(hcntct, PSS_MESSAGE, 0, (LPARAM)buf);
 				mir_free(buf);
 			}
 
 			// ...send message
-			char *AuthRepl = mir_u2a(variables_parse(g_sets.AuthRepl, hcntct).c_str());
-			CallProtoService(dbei.szModule, PS_AUTHDENY, hDbEvent, (LPARAM)AuthRepl);
-			mir_free(AuthRepl);
+			CallProtoService(dbei.szModule, PS_AUTHDENY, hDbEvent, (LPARAM)_T2A(variables_parse(g_sets.getReply(), hcntct).c_str()));
 
 			db_set_b(hcntct, "CList", "NotOnList", 1);
 			db_set_b(hcntct, "CList", "Hidden", 1);
diff --git a/plugins/StopSpamPlus/src/options.cpp b/plugins/StopSpamPlus/src/options.cpp
index 2bdc37c4b7..15a05898fb 100644
--- a/plugins/StopSpamPlus/src/options.cpp
+++ b/plugins/StopSpamPlus/src/options.cpp
@@ -82,14 +82,14 @@ public:
 
 	void onRestore(CCtrlButton*)
 	{
-		g_plugin.delSetting(g_sets.Answer.GetDBSettingName());
+		g_plugin.delSetting(g_sets.AuthRepl.GetDBSettingName());
 		g_plugin.delSetting(g_sets.Question.GetDBSettingName());
 		g_plugin.delSetting(g_sets.Congratulation.GetDBSettingName());
 
 		edtQuestion.SetText(g_sets.getQuestion());
-		edtAnswer.SetText(g_sets.Answer);
+		edtAnswer.SetText(g_sets.Answer.Default());
 		edtCongrat.SetText(g_sets.getCongrats());
-		edtReply.SetText(g_sets.AuthRepl.Default());
+		edtReply.SetText(g_sets.getReply());
 		edtDivider.SetText(g_sets.AnswSplitString.Default());
 		
 		NotifyChange();
-- 
cgit v1.2.3