summaryrefslogtreecommitdiff
path: root/protocols/MSN
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2016-06-19 14:38:21 +0000
committerGeorge Hazan <george.hazan@gmail.com>2016-06-19 14:38:21 +0000
commit0137f837ddf36dfd6e7de6decdc763a62b4fdb2c (patch)
treea662e386ece065e08b429350703b6212bc3db351 /protocols/MSN
parent0fb97def52d30f7cb3e7e849420f74427523646b (diff)
fix for a memory corruption
git-svn-id: http://svn.miranda-ng.org/main/trunk@17011 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/MSN')
-rw-r--r--protocols/MSN/src/msn_misc.cpp21
-rw-r--r--protocols/MSN/src/version.h2
2 files changed, 8 insertions, 15 deletions
diff --git a/protocols/MSN/src/msn_misc.cpp b/protocols/MSN/src/msn_misc.cpp
index 3ac46a9223..d60db4f4c4 100644
--- a/protocols/MSN/src/msn_misc.cpp
+++ b/protocols/MSN/src/msn_misc.cpp
@@ -685,35 +685,28 @@ int ThreadData::sendPacket(const char* cmd, const char* fmt, ...)
{
if (this == NULL) return 0;
- size_t strsize = 512;
- char* str = (char*)mir_alloc(strsize);
-
+ CMStringA str;
int thisTrid = 0;
if (fmt == NULL)
- strncpy_s(str, strsize, cmd, _TRUNCATE);
+ str = cmd;
else {
thisTrid = InterlockedIncrement(&mTrid);
if (fmt[0] == '\0')
- mir_snprintf(str, strsize, "%s %d", cmd, thisTrid);
+ str.AppendFormat("%s %d", cmd, thisTrid);
else {
va_list vararg;
va_start(vararg, fmt);
-
- int paramStart = mir_snprintf(str, strsize, "%s %d ", cmd, thisTrid);
- while (mir_vsnprintf(str + paramStart, strsize - paramStart - 3, fmt, vararg) == -1)
- str = (char*)mir_realloc(str, strsize += 512);
-
- str[strsize - 3] = 0;
+ str.AppendFormat("%s %d ", cmd, thisTrid);
+ str.AppendFormatV(fmt, vararg);
va_end(vararg);
}
}
if (strchr(str, '\r') == NULL)
- mir_strcat(str, "\r\n");
+ str += "\r\n";
- int result = send(str, mir_strlen(str));
- mir_free(str);
+ int result = send(str, str.GetLength());
return (result > 0) ? thisTrid : -1;
}
diff --git a/protocols/MSN/src/version.h b/protocols/MSN/src/version.h
index b8501d6681..904c641c88 100644
--- a/protocols/MSN/src/version.h
+++ b/protocols/MSN/src/version.h
@@ -21,7 +21,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 12
#define __RELEASE_NUM 1
-#define __BUILD_NUM 1
+#define __BUILD_NUM 2
#include <stdver.h>