diff options
Diffstat (limited to 'win32/PlatWin.cxx')
-rw-r--r-- | win32/PlatWin.cxx | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index 16854f254..97d7eddb5 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -285,6 +285,7 @@ static void SetLogFont(LOGFONTA &lf, const char *faceName, int characterSet, flo lf.lfCharSet = static_cast<BYTE>(characterSet); lf.lfQuality = Win32MapFontQuality(extraFontFlag); strncpy(lf.lfFaceName, faceName, sizeof(lf.lfFaceName)); + lf.lfFaceName[sizeof(lf.lfFaceName)-1] = '\0'; } /** @@ -2270,12 +2271,15 @@ PRectangle ListBoxX::GetDesiredRect() { HDC hdc = ::GetDC(lb); HFONT oldFont = SelectFont(hdc, fontCopy); SIZE textSize = {0, 0}; - int len = static_cast<int>(widestItem ? strlen(widestItem) : 0); - if (unicodeMode) { - const TextWide tbuf(widestItem, len, unicodeMode); - ::GetTextExtentPoint32W(hdc, tbuf.buffer, tbuf.tlen, &textSize); - } else { - ::GetTextExtentPoint32A(hdc, widestItem, len, &textSize); + int len = 0; + if (widestItem) { + len = static_cast<int>(strlen(widestItem)); + if (unicodeMode) { + const TextWide tbuf(widestItem, len, unicodeMode); + ::GetTextExtentPoint32W(hdc, tbuf.buffer, tbuf.tlen, &textSize); + } else { + ::GetTextExtentPoint32A(hdc, widestItem, len, &textSize); + } } TEXTMETRIC tm; ::GetTextMetrics(hdc, &tm); @@ -2439,7 +2443,11 @@ void ListBoxX::Draw(DRAWITEMSTRUCT *pDrawItem) { delete surfaceItem; pDCRT->EndDraw(); pDCRT->Release(); + } else { + delete surfaceItem; } + } else { + delete surfaceItem; } #endif } @@ -2991,6 +2999,7 @@ ElapsedTime::ElapsedTime() { littleBit = timeVal.LowPart; } else { bigBit = clock(); + littleBit = 0; } } |