From f41794f988b72fd4d7ac905f939ff868ba94e991 Mon Sep 17 00:00:00 2001 From: Neil Date: Thu, 25 Jul 2013 17:43:00 +1000 Subject: Minor changes to avoid warnings from Coverity. --- win32/PlatWin.cxx | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'win32/PlatWin.cxx') 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(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(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(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; } } -- cgit v1.2.3