Better handling of bad data in TabbedTextOut/TabbedTextExtent

Checked with:
a) Null tabstop array with non-zero number of entries
b) Negative number of entries (MSDN is wrong; it is not an error)
c) Single tabwidth of negative size
d) Single specified tabwidth of zero size
This commit is contained in:
Bill Medland 2003-01-31 03:23:18 +00:00 committed by Alexandre Julliard
parent 9dc2584b32
commit 62a80b76f2
1 changed files with 8 additions and 1 deletions

View File

@ -1216,7 +1216,10 @@ static LONG TEXT_TabbedTextOut( HDC hdc, INT x, INT y, LPCWSTR lpstr,
extent.cx = 0;
extent.cy = 0;
if (cTabStops == 1)
if (!lpTabPos)
cTabStops=0;
if (cTabStops == 1 && *lpTabPos >= /* sic */ 0)
{
defWidth = *lpTabPos;
cTabStops = 0;
@ -1226,6 +1229,8 @@ static LONG TEXT_TabbedTextOut( HDC hdc, INT x, INT y, LPCWSTR lpstr,
TEXTMETRICA tm;
GetTextMetricsA( hdc, &tm );
defWidth = 8 * tm.tmAveCharWidth;
if (cTabStops == 1)
cTabStops = 0; /* on negative *lpTabPos */
}
while (count > 0)
@ -1243,6 +1248,8 @@ static LONG TEXT_TabbedTextOut( HDC hdc, INT x, INT y, LPCWSTR lpstr,
tabPos = x + extent.cx;
else if (cTabStops > 0)
tabPos = nTabOrg + *lpTabPos;
else if (defWidth <= 0)
tabPos = x + extent.cx;
else
tabPos = nTabOrg + ((x + extent.cx - nTabOrg) / defWidth + 1) * defWidth;
if (fDisplayText)