diff options
author | George Hazan <george.hazan@gmail.com> | 2015-05-14 19:05:32 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-05-14 19:05:32 +0000 |
commit | 2a884a193239118e9ff76d7a29dae5a84fab1122 (patch) | |
tree | 3841609097524f26548e9b9c0157e6891ee5247d /protocols/MSN/src/msn_threads.cpp | |
parent | f4048a55be034634434050cfa7748aa9f5d18126 (diff) |
- crash fix;
- code cleaning
git-svn-id: http://svn.miranda-ng.org/main/trunk@13594 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/MSN/src/msn_threads.cpp')
-rw-r--r-- | protocols/MSN/src/msn_threads.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
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);
|