[PATCH] user32/text: Stop crash when Tab Length is zero
Alistair Leslie-Hughes
leslie_alistair at hotmail.com
Mon Feb 29 01:20:13 CST 2016
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
---
dlls/user32/tests/text.c | 12 ++++++++++++
dlls/user32/text.c | 2 +-
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/dlls/user32/tests/text.c b/dlls/user32/tests/text.c
index df8d3ee..5827f64 100644
--- a/dlls/user32/tests/text.c
+++ b/dlls/user32/tests/text.c
@@ -44,6 +44,7 @@ static void test_DrawTextCalcRect(void)
static WCHAR emptystringW[] = { 0 };
static CHAR wordbreak_text[] = "line1 line2";
static WCHAR wordbreak_textW[] = {'l','i','n','e','1',' ','l','i','n','e','2',0};
+ static char tabstring[] = "one\ttwo";
INT textlen, textheight, heightcheck;
RECT rect = { 0, 0, 100, 0 };
BOOL ret;
@@ -580,6 +581,17 @@ static void test_DrawTextCalcRect(void)
ok(textheight >= heightcheck * 6, "Got unexpected textheight %d, expected at least %d.\n",
textheight, heightcheck * 6);
+ /* DT_TABSTOP | DT_EXPANDTABS tests */
+ textheight = DrawTextA(hdc, tabstring, -1, &rect, DT_TABSTOP | DT_EXPANDTABS);
+ ok(textheight >= heightcheck, "Got unexpected textheight %d, expected at least %d.\n",
+ textheight, heightcheck);
+
+ memset(&dtp, 0, sizeof(dtp));
+ dtp.cbSize = sizeof(dtp);
+ textheight = DrawTextExA(hdc, tabstring, -1, &rect, DT_TABSTOP | DT_EXPANDTABS, &dtp);
+ ok(textheight >= heightcheck, "Got unexpected textheight %d, expected at least %d.\n",
+ textheight, heightcheck);
+
SelectObject(hdc, hOldFont);
ret = DeleteObject(hFont);
ok( ret, "DeleteObject error %u\n", GetLastError());
diff --git a/dlls/user32/text.c b/dlls/user32/text.c
index 7b0302e..2ac3afd 100644
--- a/dlls/user32/text.c
+++ b/dlls/user32/text.c
@@ -948,7 +948,7 @@ INT WINAPI DrawTextExW( HDC hdc, LPWSTR str, INT i_count,
if (flags & DT_EXPANDTABS)
{
- int tabstop = ((flags & DT_TABSTOP) && dtp) ? dtp->iTabLength : 8;
+ int tabstop = ((flags & DT_TABSTOP) && dtp && dtp->iTabLength) ? dtp->iTabLength : 8;
tabwidth = tm.tmAveCharWidth * tabstop;
}
--
1.9.1
More information about the wine-patches
mailing list