diff options
author | George Hazan <george.hazan@gmail.com> | 2014-07-31 18:37:01 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-07-31 18:37:01 +0000 |
commit | 4b25736d4b3565e4e9945d191d15e0740dce6afc (patch) | |
tree | f047bb7f5dfbb7c5ad0cf1dbe8bef7618d294f14 | |
parent | 9631bfe941ed0cbba6e720b7efd92966e0c6a670 (diff) |
various memory allocation problems fixed
git-svn-id: http://svn.miranda-ng.org/main/trunk@10006 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | plugins/NewXstatusNotify/src/main.cpp | 29 | ||||
-rw-r--r-- | plugins/NewXstatusNotify/src/version.h | 14 | ||||
-rw-r--r-- | plugins/NewXstatusNotify/src/xstatus.cpp | 32 |
3 files changed, 26 insertions, 49 deletions
diff --git a/plugins/NewXstatusNotify/src/main.cpp b/plugins/NewXstatusNotify/src/main.cpp index 344c7acf01..7a7f9970ce 100644 --- a/plugins/NewXstatusNotify/src/main.cpp +++ b/plugins/NewXstatusNotify/src/main.cpp @@ -535,7 +535,7 @@ int ProcessStatus(DBCONTACTWRITESETTING *cws, MCONTACT hContact) int ProcessExtraStatus(DBCONTACTWRITESETTING *cws, MCONTACT hContact)
{
XSTATUSCHANGE *xsc;
- STATUSMSGINFO smi;
+ STATUSMSGINFO smi = { 0 };
char *szProto = GetContactProto(hContact);
smi.hContact = hContact;
@@ -556,8 +556,8 @@ int ProcessExtraStatus(DBCONTACTWRITESETTING *cws, MCONTACT hContact) if (strstr(cws->szSetting, "title")) {
smi.compare = CompareStatusMsg(&smi, cws, szSetting);
if (smi.compare == COMPARE_SAME) {
- mir_free(smi.newstatusmsg);
- mir_free(smi.oldstatusmsg);
+ replaceStrT(smi.newstatusmsg, 0);
+ replaceStrT(smi.oldstatusmsg, 0);
}
if (cws->value.type == DBVT_DELETED)
@@ -573,8 +573,8 @@ int ProcessExtraStatus(DBCONTACTWRITESETTING *cws, MCONTACT hContact) mir_snprintf(dbSetting, SIZEOF(dbSetting), "%s%s", szSetting, "Msg");
smi.compare = CompareStatusMsg(&smi, cws, dbSetting);
if (smi.compare == COMPARE_SAME) {
- mir_free(smi.newstatusmsg);
- mir_free(smi.oldstatusmsg);
+ replaceStrT(smi.newstatusmsg, 0);
+ replaceStrT(smi.oldstatusmsg, 0);
}
if (cws->value.type == DBVT_DELETED)
@@ -595,8 +595,8 @@ int ProcessExtraStatus(DBCONTACTWRITESETTING *cws, MCONTACT hContact) if (strcmp(cws->szSetting, "XStatusName") == 0) {
smi.compare = CompareStatusMsg(&smi, cws, "LastXStatusName");
if (smi.compare == COMPARE_SAME) {
- mir_free(smi.newstatusmsg);
- mir_free(smi.oldstatusmsg);
+ replaceStrT(smi.newstatusmsg, 0);
+ replaceStrT(smi.oldstatusmsg, 0);
}
if (cws->value.type == DBVT_DELETED)
@@ -610,8 +610,8 @@ int ProcessExtraStatus(DBCONTACTWRITESETTING *cws, MCONTACT hContact) else if (!strcmp(cws->szSetting, "XStatusMsg")/* || strcmp(cws->szSetting, "StatusNote") == 0*/) {
smi.compare = CompareStatusMsg(&smi, cws, "LastXStatusMsg");
if (smi.compare == COMPARE_SAME) {
- mir_free(smi.newstatusmsg);
- mir_free(smi.oldstatusmsg);
+ replaceStrT(smi.newstatusmsg, 0);
+ replaceStrT(smi.oldstatusmsg, 0);
}
if (cws->value.type == DBVT_DELETED)
@@ -706,8 +706,7 @@ int ProcessStatusMessage(DBCONTACTWRITESETTING *cws, MCONTACT hContact) _tcsncpy(buff, smi.newstatusmsg, opt.PSMsgLen);
buff[opt.PSMsgLen] = 0;
_tcscat(buff, _T("..."));
- mir_free(smi.newstatusmsg);
- smi.newstatusmsg = mir_tstrdup(buff);
+ replaceStrT(smi.newstatusmsg, buff);
}
TCHAR *str, protoname[MAX_PATH] = { 0 };
@@ -745,8 +744,7 @@ int ProcessStatusMessage(DBCONTACTWRITESETTING *cws, MCONTACT hContact) if (copyText) {
mir_free(smi.newstatusmsg);
- smi.newstatusmsg = mir_tstrdup(copyText);
- mir_free(copyText);
+ smi.newstatusmsg = copyText;
}
}
@@ -787,9 +785,10 @@ int ProcessStatusMessage(DBCONTACTWRITESETTING *cws, MCONTACT hContact) LogToFile(stzText);
mir_free(str);
}
+
skip_notify:
- mir_free(smi.newstatusmsg);
- mir_free(smi.oldstatusmsg);
+ replaceStrT(smi.newstatusmsg, 0);
+ replaceStrT(smi.oldstatusmsg, 0);
return 1;
}
diff --git a/plugins/NewXstatusNotify/src/version.h b/plugins/NewXstatusNotify/src/version.h index 68b765b6bd..1f7c128b06 100644 --- a/plugins/NewXstatusNotify/src/version.h +++ b/plugins/NewXstatusNotify/src/version.h @@ -1,14 +1,14 @@ -#define __MAJOR_VERSION 1
-#define __MINOR_VERSION 4
-#define __RELEASE_NUM 0
-#define __BUILD_NUM 9
+#define __MAJOR_VERSION 1
+#define __MINOR_VERSION 4
+#define __RELEASE_NUM 0
+#define __BUILD_NUM 10
#include <stdver.h>
#define __PLUGIN_NAME "xStatus notify"
#define __FILENAME "NewXstatusNotify.dll"
#define __DESCRIPTION "Notifies you when a contact changes his/her (X)status or status message."
-#define __AUTHOR "Luca Santarelli, Vasilich, yaho"
+#define __AUTHOR "Luca Santarelli, Vasilich, yaho"
#define __AUTHOREMAIL "yaho@miranda-easy.net"
-#define __AUTHORWEB "http://miranda-ng.org/p/NewXstatusNotify/"
-#define __COPYRIGHT "© 2001-2004 Luca Santarelli, 2005-2007 Vasilich, 2007-2011 yaho"
+#define __AUTHORWEB "http://miranda-ng.org/p/NewXstatusNotify/"
+#define __COPYRIGHT "© 2001-2004 Luca Santarelli, 2005-2007 Vasilich, 2007-2011 yaho"
diff --git a/plugins/NewXstatusNotify/src/xstatus.cpp b/plugins/NewXstatusNotify/src/xstatus.cpp index 366a750dc8..7ca0ed3879 100644 --- a/plugins/NewXstatusNotify/src/xstatus.cpp +++ b/plugins/NewXstatusNotify/src/xstatus.cpp @@ -37,7 +37,6 @@ void FreeXSC(XSTATUSCHANGE *xsc) mir_free(xsc->stzTitle);
mir_free(xsc->stzText);
mir_free(xsc);
- xsc = NULL;
}
}
@@ -236,8 +235,7 @@ void ShowXStatusPopup(XSTATUSCHANGE *xsc) if (copyText) {
mir_free(xsc->stzText);
- xsc->stzText = mir_tstrdup(copyText);
- mir_free(copyText);
+ xsc->stzText = copyText;
}
}
@@ -263,10 +261,8 @@ void BlinkXStatusIcon(XSTATUSCHANGE *xsc) }
break;
case TYPE_ICQ_XSTATUS:
- {
- int statusId = db_get_b(xsc->hContact, xsc->szProto, "XStatusId", 0);
- hIcon = (HICON)CallProtoService(xsc->szProto, PS_GETCUSTOMSTATUSICON, statusId, LR_SHARED);
- }
+ int statusId = db_get_b(xsc->hContact, xsc->szProto, "XStatusId", 0);
+ hIcon = (HICON)CallProtoService(xsc->szProto, PS_GETCUSTOMSTATUSICON, statusId, LR_SHARED);
}
}
@@ -534,32 +530,14 @@ void AddXStatusEventThread(void *arg) void AddSMsgEventThread(void *arg)
{
MCONTACT hContact = (MCONTACT)arg;
- STATUSMSGINFO smi;
+ STATUSMSGINFO smi;
smi.hContact = hContact;
smi.proto = GetContactProto(hContact);
if (smi.proto == NULL)
return;
- DBVARIANT dbv;
- if (!db_get_s(smi.hContact, "CList", "StatusMsg", &dbv, 0)) {
- switch (dbv.type) {
- case DBVT_ASCIIZ:
- smi.newstatusmsg = mir_dupToUnicodeEx(dbv.pszVal, CP_ACP);
- break;
- case DBVT_UTF8:
- smi.newstatusmsg = mir_dupToUnicodeEx(dbv.pszVal, CP_UTF8);
- break;
- case DBVT_WCHAR:
- smi.newstatusmsg = mir_wstrdup(dbv.pwszVal);
- break;
- default:
- smi.newstatusmsg = NULL;
- break;
- }
- db_free(&dbv);
- }
-
+ smi.newstatusmsg = db_get_tsa(smi.hContact, "CList", "StatusMsg");
LogSMsgToDB(&smi, templates.LogSMsgOpening);
mir_free(smi.newstatusmsg);
}
|