aboutsummaryrefslogtreecommitdiffhomepage
path: root/win32/PlatWin.cxx
diff options
context:
space:
mode:
authorNeil <nyamatongwe@gmail.com>2013-07-25 17:43:00 +1000
committerNeil <nyamatongwe@gmail.com>2013-07-25 17:43:00 +1000
commitf41794f988b72fd4d7ac905f939ff868ba94e991 (patch)
treefc12354ce053aef134030bb3ebceaf477c0666b4 /win32/PlatWin.cxx
parent28af18d2d1226689923cadd7030d2f085253e6a3 (diff)
downloadscintilla-mirror-f41794f988b72fd4d7ac905f939ff868ba94e991.tar.gz
Minor changes to avoid warnings from Coverity.
Diffstat (limited to 'win32/PlatWin.cxx')
-rw-r--r--win32/PlatWin.cxx21
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;
}
}