From 595191bba9f92c3dad805a4745071bd99bf25175 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 4 Oct 2006 19:43:20 +0000 Subject: [PATCH] fix the length passed to wxMB2WC (replaces patch 1554431); don't use (and especially don't overflow) fixed size buffer in the same function (just how many bugs can there be in 5 lines of code?) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41630 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/msw/wince/time.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/msw/wince/time.cpp b/src/msw/wince/time.cpp index 62b10ed256..965502e15b 100644 --- a/src/msw/wince/time.cpp +++ b/src/msw/wince/time.cpp @@ -500,18 +500,20 @@ strftime(char * const s, const size_t maxsize, const char *format, const struct extern "C" { -size_t wcsftime(wchar_t* const s, const size_t maxsize, const wchar_t *format, const struct tm * const t) +size_t wcsftime(wchar_t *s, + const size_t maxsize, + const wchar_t *format, + const struct tm *t) { - char sBuf[256]; - sBuf[0] = 0; - + wxCharBuffer sBuf(maxsize/sizeof(wchar_t)); + wxString formatStr(format); wxCharBuffer bufFormatStr(formatStr.mb_str()); - - size_t sz = strftime(sBuf, maxsize, bufFormatStr, t); - - wxMB2WC(s, sBuf, strlen(sBuf)); - + + size_t sz = strftime(sBuf, maxsize/sizeof(wchar_t), bufFormatStr, t); + + wxMB2WC(s, sBuf, maxsize); + return sz; } -- 2.45.2