From 2a884a193239118e9ff76d7a29dae5a84fab1122 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 14 May 2015 19:05:32 +0000 Subject: - crash fix; - code cleaning git-svn-id: http://svn.miranda-ng.org/main/trunk@13594 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/MSN/src/msn_threads.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'protocols/MSN/src/msn_threads.cpp') diff --git a/protocols/MSN/src/msn_threads.cpp b/protocols/MSN/src/msn_threads.cpp index 34c446d3e6..208d8e1287 100644 --- a/protocols/MSN/src/msn_threads.cpp +++ b/protocols/MSN/src/msn_threads.cpp @@ -72,18 +72,18 @@ void __cdecl CMsnProto::msn_keepAliveThread(void*) ///////////////////////////////////////////////////////////////////////////////////////// // MSN server thread - read and process commands from a server -static bool ReallocInfoBuffer(ThreadData *info, int mDataSize) + +static bool ReallocInfoBuffer(ThreadData *info, size_t mDataSize) { char *mData = (char*)mir_realloc(info->mData, mDataSize+1); - if (mData) { - info->mData = mData; - info->mDataSize = mDataSize; - ZeroMemory(&mData[info->mBytesInData], info->mDataSize-info->mBytesInData+1); - return true; - } - return false; -} + if (mData == NULL) + return false; + info->mData = mData; + info->mDataSize = mDataSize; + ZeroMemory(&mData[info->mBytesInData], info->mDataSize-info->mBytesInData+1); + return true; +} void __cdecl CMsnProto::MSNServerThread(void* arg) { @@ -202,18 +202,18 @@ void __cdecl CMsnProto::MSNServerThread(void* arg) if (peol == NULL) break; - if (info->mBytesInData < peol - info->mData + 2) + int msgLen = (int)(peol - info->mData); + if (info->mBytesInData < msgLen + 2) break; //wait for full line end - char msg[1024]; - memcpy(msg, info->mData, peol - info->mData); msg[peol - info->mData] = 0; + ptrA msg(mir_strndup(info->mData, msgLen)); if (*++peol != '\n') debugLogA("Dodgy line ending to command: ignoring"); else peol++; - info->mBytesInData -= peol - info->mData; + info->mBytesInData -= msgLen; memmove(info->mData, peol, info->mBytesInData); debugLogA("RECV: %s", msg); -- cgit v1.2.3