From c4f4b01b058d840c350581a58671d9f531d0c310 Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Sat, 8 Apr 2006 22:27:34 +0200 Subject: [PATCH] gdi32: GetCharABCWidthsW should not crash on a NULL handle. --- dlls/gdi/font.c | 2 ++ dlls/gdi/tests/font.c | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/dlls/gdi/font.c b/dlls/gdi/font.c index ffebd7e0112..1e17d5aa759 100644 --- a/dlls/gdi/font.c +++ b/dlls/gdi/font.c @@ -2330,6 +2330,8 @@ BOOL WINAPI GetCharABCWidthsW( HDC hdc, UINT firstChar, UINT lastChar, unsigned int i; BOOL ret = FALSE; + if (!dc) return FALSE; + if(dc->gdiFont) ret = WineEngGetCharABCWidths( dc->gdiFont, firstChar, lastChar, abc ); else diff --git a/dlls/gdi/tests/font.c b/dlls/gdi/tests/font.c index 9ed33b77410..ef0b9b24abf 100644 --- a/dlls/gdi/tests/font.c +++ b/dlls/gdi/tests/font.c @@ -323,6 +323,18 @@ static void test_GdiGetCharDimensions(void) DeleteDC(hdc); } +static void test_GetCharABCWidthsW(void) +{ + BOOL ret; + ABC abc[1]; + typedef BOOL (WINAPI *fnGetCharABCWidthsW)(HDC hdc, UINT first, UINT last, LPABC abc); + fnGetCharABCWidthsW GetCharABCWidthsW = (fnGetCharABCWidthsW)GetProcAddress(LoadLibrary("gdi32"), "GetCharABCWidthsW"); + if (!GetCharABCWidthsW) return; + + ret = GetCharABCWidthsW(NULL, 'a', 'a', abc); + ok(!ret, "GetCharABCWidthsW should have returned FALSE\n"); +} + static void test_text_extents(void) { LOGFONTA lf; @@ -353,5 +365,6 @@ START_TEST(font) test_bitmap_font(); test_bitmap_font_metrics(); test_GdiGetCharDimensions(); + test_GetCharABCWidthsW(); test_text_extents(); } -- 2.11.4.GIT