Commit 62a80b76 authored by Bill Medland's avatar Bill Medland Committed by Alexandre Julliard

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
parent 9dc2584b
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment