From c62ba7b8f551e464e9b217db60a9613baca64f1e Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 30 Jan 2013 14:56:20 +0000 Subject: fix to prevent C++ runtime from shutting down Miranda due to wrong data formats etc git-svn-id: http://svn.miranda-ng.org/main/trunk@3368 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Scriver/src/chat/log.cpp | 6 +++--- plugins/TabSRMM/src/chat/log.cpp | 3 ++- src/core/miranda.cpp | 9 +++++++++ src/core/stdchat/src/log.cpp | 3 ++- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/plugins/Scriver/src/chat/log.cpp b/plugins/Scriver/src/chat/log.cpp index 7cffea1360..7b886c0ee3 100644 --- a/plugins/Scriver/src/chat/log.cpp +++ b/plugins/Scriver/src/chat/log.cpp @@ -580,7 +580,8 @@ static void LogEventIEView(LOGSTREAMDATA *streamData, TCHAR *ptszNick) TCHAR* MakeTimeStamp( TCHAR* pszStamp, time_t time) { static TCHAR szTime[30]; - _tcsftime(szTime, 29, pszStamp, localtime(&time)); + if ( !_tcsftime(szTime, SIZEOF(szTime)-1, pszStamp, localtime(&time))) + _tcsncpy(szTime, TranslateT(""), SIZEOF(szTime)); return szTime; } @@ -973,7 +974,6 @@ void LoadMsgLogBitmaps(void) void FreeMsgLogBitmaps(void) { - int i; - for (i = 0; i < SIZEOF(pLogIconBmpBits); i++) + for (int i = 0; i < SIZEOF(pLogIconBmpBits); i++) mir_free(pLogIconBmpBits[i]); } diff --git a/plugins/TabSRMM/src/chat/log.cpp b/plugins/TabSRMM/src/chat/log.cpp index a421c1aefb..a6cfde546c 100644 --- a/plugins/TabSRMM/src/chat/log.cpp +++ b/plugins/TabSRMM/src/chat/log.cpp @@ -750,7 +750,8 @@ static void AddEventToBuffer(char **buffer, int *bufferEnd, int *bufferAlloced, TCHAR* MakeTimeStamp(TCHAR* pszStamp, time_t time) { static TCHAR szTime[30]; - _tcsftime(szTime, 29, pszStamp, localtime(&time)); + if ( !_tcsftime(szTime, SIZEOF(szTime)-1, pszStamp, localtime(&time))) + _tcsncpy(szTime, TranslateT(""), SIZEOF(szTime)); return szTime; } diff --git a/src/core/miranda.cpp b/src/core/miranda.cpp index 66a3ca8e80..780283b48f 100644 --- a/src/core/miranda.cpp +++ b/src/core/miranda.cpp @@ -208,11 +208,20 @@ void CheckRestart() } } +static void crtErrorHandler(const wchar_t*, const wchar_t*, const wchar_t*, unsigned, uintptr_t) +{ +} + int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE, LPTSTR cmdLine, int) { hInst = hInstance; hMainThreadId = GetCurrentThreadId(); + _set_invalid_parameter_handler(&crtErrorHandler); + #ifdef _DEBUG + _CrtSetReportMode(_CRT_ASSERT, 0); + #endif + CmdLine_Parse(cmdLine); setlocale(LC_ALL, ""); diff --git a/src/core/stdchat/src/log.cpp b/src/core/stdchat/src/log.cpp index 86b2f41b0a..193c9bb719 100644 --- a/src/core/stdchat/src/log.cpp +++ b/src/core/stdchat/src/log.cpp @@ -318,7 +318,8 @@ static void AddEventToBuffer(char **buffer, int *bufferEnd, int *bufferAlloced, TCHAR* MakeTimeStamp( TCHAR* pszStamp, time_t time) { static TCHAR szTime[30]; - _tcsftime(szTime, 29, pszStamp, localtime(&time)); + if ( !_tcsftime(szTime, SIZEOF(szTime)-1, pszStamp, localtime(&time))) + _tcsncpy(szTime, TranslateT(""), SIZEOF(szTime)); return szTime; } -- cgit v1.2.3