From 37e5a98b8a26c3c62edbadb073485ec129b8d66c Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 4 Jan 2014 22:28:29 +0000 Subject: two memory leaks in Jabber git-svn-id: http://svn.miranda-ng.org/main/trunk@7507 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/TipperYM/src/subst.cpp | 11 +++-------- protocols/JabberG/src/jabber_iq.h | 4 ++++ protocols/JabberG/src/jabber_proto.cpp | 22 ++++++++-------------- 3 files changed, 15 insertions(+), 22 deletions(-) diff --git a/plugins/TipperYM/src/subst.cpp b/plugins/TipperYM/src/subst.cpp index 6fdf551015..74d6990c98 100644 --- a/plugins/TipperYM/src/subst.cpp +++ b/plugins/TipperYM/src/subst.cpp @@ -887,8 +887,7 @@ TCHAR *GetProtoExtraStatusMessage(char *szProto) if (!szProto) return NULL; - if (!db_get_ts(0, szProto, "XStatusMsg", &dbv)) - { + if (!db_get_ts(0, szProto, "XStatusMsg", &dbv)) { if (_tcslen(dbv.ptszVal) != 0) swzText = mir_tstrdup(dbv.ptszVal); db_free(&dbv); @@ -896,15 +895,11 @@ TCHAR *GetProtoExtraStatusMessage(char *szProto) if (ServiceExists(MS_VARS_FORMATSTRING)) { HANDLE hContact = db_find_first(); char *proto = GetContactProto(hContact); - while(!proto) - { + while(!proto) { hContact = db_find_next(hContact); if (hContact) - { proto = GetContactProto(hContact); - } - else - { + else { hContact = NULL; break; } diff --git a/protocols/JabberG/src/jabber_iq.h b/protocols/JabberG/src/jabber_iq.h index acaa90a47d..f98fdb5989 100644 --- a/protocols/JabberG/src/jabber_iq.h +++ b/protocols/JabberG/src/jabber_iq.h @@ -78,6 +78,10 @@ public: { memset(this, 0, sizeof(*this)); } + __forceinline ~CJabberIqInfo() + { + mir_free(m_szReceiver); + } __forceinline void SetReceiver(const TCHAR *szReceiver) { replaceStrT(m_szReceiver, szReceiver); diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index f73fe0cb0d..73c585f408 100644 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -1333,22 +1333,16 @@ int __cdecl CJabberProto::SetAwayMsg(int status, const TCHAR *msg) return 1; } - TCHAR *newModeMsg = mir_tstrdup(msg); + if ((*szMsg == NULL && msg == NULL) || (*szMsg != NULL && msg != NULL && !lstrcmp(*szMsg, msg))) + return 0; // Message is the same, no update needed - if ((*szMsg == NULL && newModeMsg == NULL) || - (*szMsg != NULL && newModeMsg != NULL && !lstrcmp(*szMsg, newModeMsg))) { - // Message is the same, no update needed - mir_free(newModeMsg); - } - else { - // Update with the new mode message - replaceStrT(*szMsg, newModeMsg); - // Send a presence update if needed - lck.unlock(); - if (status == m_iStatus) - SendPresence(m_iStatus, true); - } + // Update with the new mode message + replaceStrT(*szMsg, msg); + // Send a presence update if needed + lck.unlock(); + if (status == m_iStatus) + SendPresence(m_iStatus, true); return 0; } -- cgit v1.2.3