summaryrefslogtreecommitdiff
path: root/plugins/SimpleStatusMsg
diff options
context:
space:
mode:
authorSzymon Tokarz <wsx22@o2.pl>2013-12-13 21:49:52 +0000
committerSzymon Tokarz <wsx22@o2.pl>2013-12-13 21:49:52 +0000
commitbbce51b07660e652f7f5ebd9ce8ceb1bba6e6389 (patch)
tree9148a1e6663c97bcf1283f0b443ceef17d47c47f /plugins/SimpleStatusMsg
parent2c73c95d00f1637031042a75fc99d2a4ba92d21b (diff)
Simple Status Message
- fix some memory related issues. (Schould fix ticket #510) git-svn-id: http://svn.miranda-ng.org/main/trunk@7196 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/SimpleStatusMsg')
-rw-r--r--plugins/SimpleStatusMsg/src/awaymsg.cpp47
-rw-r--r--plugins/SimpleStatusMsg/src/main.cpp3
-rw-r--r--plugins/SimpleStatusMsg/src/msgbox.cpp9
3 files changed, 14 insertions, 45 deletions
diff --git a/plugins/SimpleStatusMsg/src/awaymsg.cpp b/plugins/SimpleStatusMsg/src/awaymsg.cpp
index 8fcef3f0ad..1946aa9b47 100644
--- a/plugins/SimpleStatusMsg/src/awaymsg.cpp
+++ b/plugins/SimpleStatusMsg/src/awaymsg.cpp
@@ -329,24 +329,7 @@ static char *StrFindURL(char *pszStr)
static INT_PTR GoToURLMsgCommand(WPARAM wParam, LPARAM lParam)
{
- DBVARIANT dbv;
- char *szMsg;
-
-
- int unicode = !db_get((HANDLE)wParam, "CList", "StatusMsg", &dbv) && (dbv.type == DBVT_UTF8 || dbv.type == DBVT_WCHAR);
- db_free(&dbv);
- if (unicode)
- {
- db_get_ws((HANDLE)wParam, "CList", "StatusMsg", &dbv);
- szMsg = mir_u2a(dbv.pwszVal);
- }
- else
-
- {
- db_get_s((HANDLE)wParam, "CList", "StatusMsg", &dbv);
- szMsg = mir_strdup(dbv.pszVal);
- }
- db_free(&dbv);
+ ptrA szMsg(db_get_sa((HANDLE)wParam, "CList", "StatusMsg"));
char *szURL = StrFindURL(szMsg);
if (szURL != NULL)
@@ -363,7 +346,6 @@ static INT_PTR GoToURLMsgCommand(WPARAM wParam, LPARAM lParam)
mir_free(szMsgURL);
}
}
- mir_free(szMsg);
return 0;
}
@@ -373,13 +355,11 @@ static int AwayMsgPreBuildMenu(WPARAM wParam, LPARAM lParam)
TCHAR str[128];
char *szProto = GetContactProto((HANDLE)wParam);
int iHidden = szProto ? db_get_b((HANDLE)wParam, szProto, "ChatRoom", 0) : 0;
- char *szMsg;
int iStatus;
CLISTMENUITEM clmi = { sizeof(clmi) };
clmi.cbSize = sizeof(clmi);
clmi.flags = CMIM_FLAGS | CMIF_HIDDEN | CMIF_TCHAR;
-
if (!iHidden) {
iHidden = 1;
iStatus = db_get_w((HANDLE)wParam, szProto, "Status", ID_STATUS_OFFLINE);
@@ -396,23 +376,11 @@ static int AwayMsgPreBuildMenu(WPARAM wParam, LPARAM lParam)
Menu_ModifyItem(hAwayMsgMenuItem, &clmi);
Skin_ReleaseIcon(clmi.hIcon);
- clmi.flags = CMIM_FLAGS | CMIF_HIDDEN | CMIF_TCHAR;
- if (!iHidden) {
- DBVARIANT dbv;
-
- int unicode = !db_get((HANDLE)wParam, "CList", "StatusMsg", &dbv) && (dbv.type == DBVT_UTF8 || dbv.type == DBVT_WCHAR);
- db_free(&dbv);
- if (unicode) {
- db_get_ws((HANDLE)wParam, "CList", "StatusMsg", &dbv);
- szMsg = mir_u2a(dbv.pwszVal);
- }
- else {
- db_get_s((HANDLE)wParam, "CList", "StatusMsg", &dbv);
- szMsg = mir_strdup(dbv.pszVal);
- }
- db_free(&dbv);
+ ptrA szMsg(db_get_sa((HANDLE)wParam, "CList", "StatusMsg"));
- if (db_get_b(NULL, "SimpleStatusMsg", "ShowCopy", 1) && szMsg && *szMsg != '\0') {
+ clmi.flags = CMIM_FLAGS | CMIF_HIDDEN | CMIF_TCHAR;
+ if (!iHidden && szMsg != NULL) {
+ if (db_get_b(NULL, "SimpleStatusMsg", "ShowCopy", 1)) {
clmi.flags = CMIM_FLAGS | CMIM_NAME | CMIF_TCHAR;
mir_sntprintf(str, SIZEOF(str), TranslateT("Copy %s Message"), pcli->pfnGetStatusModeDescription(iStatus, 0));
clmi.ptszName = str;
@@ -421,15 +389,16 @@ static int AwayMsgPreBuildMenu(WPARAM wParam, LPARAM lParam)
Menu_ModifyItem(hCopyMsgMenuItem, &clmi);
clmi.flags = CMIM_FLAGS | CMIF_HIDDEN | CMIF_TCHAR;
- if (!iHidden) {
+ if (!iHidden && szMsg != NULL) {
if (db_get_b(NULL, "SimpleStatusMsg", "ShowGoToURL", 1) && StrFindURL(szMsg) != NULL) {
clmi.flags = CMIM_FLAGS | CMIM_NAME | CMIF_TCHAR;
mir_sntprintf(str, SIZEOF(str), TranslateT("&Go to URL in %s Message"), pcli->pfnGetStatusModeDescription(iStatus, 0));
clmi.ptszName = str;
}
- mir_free(szMsg);
+
}
Menu_ModifyItem(hGoToURLMenuItem, &clmi);
+
return 0;
}
diff --git a/plugins/SimpleStatusMsg/src/main.cpp b/plugins/SimpleStatusMsg/src/main.cpp
index c0d89db564..fc120c6acb 100644
--- a/plugins/SimpleStatusMsg/src/main.cpp
+++ b/plugins/SimpleStatusMsg/src/main.cpp
@@ -1682,9 +1682,7 @@ static int CSStatusChange(WPARAM wParam, LPARAM lParam)
mir_snprintf(buff, SIZEOF(buff), "SMsg%d", j);
if (!db_get_ts(NULL, "SimpleStatusMsg", buff, &dbv))
{
-
if (!lstrcmp(dbv.ptszVal, szMsgW))
-
{
found = TRUE;
mir_snprintf(szSetting, SIZEOF(szSetting), "Last%sMsg", ps[i]->szName);
@@ -1692,6 +1690,7 @@ static int CSStatusChange(WPARAM wParam, LPARAM lParam)
db_free(&dbv);
break;
}
+ db_free(&dbv);
}
}
diff --git a/plugins/SimpleStatusMsg/src/msgbox.cpp b/plugins/SimpleStatusMsg/src/msgbox.cpp
index ad4e67970f..0bfa7111c5 100644
--- a/plugins/SimpleStatusMsg/src/msgbox.cpp
+++ b/plugins/SimpleStatusMsg/src/msgbox.cpp
@@ -781,9 +781,9 @@ void SetEditControlText(struct MsgBoxData *data, HWND hwndDlg, int iStatus)
if (!db_get(NULL, "SimpleStatusMsg", setting, &dbv))
{
- if (dbv.pszVal)
+ if (dbv.pszVal && strlen(dbv.pszVal))
{
- if (strlen(dbv.pszVal) && !db_get_ts(NULL, "SimpleStatusMsg", dbv.pszVal, &dbv2))
+ if (!db_get_ts(NULL, "SimpleStatusMsg", dbv.pszVal, &dbv2))
{
if (dbv2.ptszVal && lstrlen(dbv2.ptszVal))
{
@@ -1154,8 +1154,6 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA
if (bCurrentStatus)
copy_init_data->m_iStatus = ID_STATUS_CURRENT;
- mir_free(init_data);
-
mir_subclassWindow( GetDlgItem(hwndDlg, IDC_EDIT1), EditBoxSubProc);
if (!init_data->m_bOnEvent && IsWindowEnabled(GetDlgItem(hwndDlg, IDC_EDIT1)))
{
@@ -1165,6 +1163,8 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA
else
SetFocus(GetDlgItem(hwndDlg, IDC_OK));
+ mir_free(init_data);
+
if (!db_get_b(NULL, "SimpleStatusMsg", "WinCentered", 1))
{
WINDOWPLACEMENT wp;
@@ -1323,6 +1323,7 @@ INT_PTR CALLBACK AwayMsgBoxDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARA
db_free(&dbv);
break;
}
+ db_free(&dbv);
}
}