[2/3] gdi32: Set error code in CloseFigure() on NULL hdc
Nikolay Sivov
bunglehead at gmail.com
Sat Jan 10 13:44:18 CST 2009
Changelog:
- Set error code in CloseFigure() on NULL hdc
>From 9023954505846a8e9ffc5007142fba560834978c Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <bunglehead at gmail.com>
Date: Sat, 10 Jan 2009 22:12:44 +0300
Subject: Set error code in CloseFigure() on NULL hdc
---
dlls/gdi32/path.c | 6 +++++-
dlls/gdi32/tests/path.c | 11 +++++++++++
2 files changed, 16 insertions(+), 1 deletions(-)
diff --git a/dlls/gdi32/path.c b/dlls/gdi32/path.c
index 8df8a1b..e9cb7bb 100644
--- a/dlls/gdi32/path.c
+++ b/dlls/gdi32/path.c
@@ -222,7 +222,11 @@ BOOL WINAPI CloseFigure(HDC hdc)
BOOL ret = TRUE;
DC *dc = get_dc_ptr( hdc );
- if(!dc) return FALSE;
+ if(!dc)
+ {
+ SetLastError(ERROR_INVALID_HANDLE);
+ return FALSE;
+ }
if(dc->funcs->pCloseFigure)
ret = dc->funcs->pCloseFigure(dc->physDev);
diff --git a/dlls/gdi32/tests/path.c b/dlls/gdi32/tests/path.c
index 58e8467..7944ed5 100644
--- a/dlls/gdi32/tests/path.c
+++ b/dlls/gdi32/tests/path.c
@@ -397,6 +397,17 @@ static void test_closefigure(void) {
int nSize, nSizeWitness;
HDC hdc = GetDC(0);
+ /* outside path brackets */
+ SetLastError(0xdeadbeef);
+ retb = CloseFigure(hdc);
+ ok(!retb, "CloseFigure() should fail outside path brackets\n");
+ ok(GetLastError() == ERROR_CAN_NOT_COMPLETE, "Expected ERROR_CAN_NOT_COMPLETE, got %u\n", GetLastError());
+ /* invalid dc handle */
+ SetLastError(0xdeadbeef);
+ retb = CloseFigure(NULL);
+ ok(!retb, "CloseFigure() should fail on invalid hdc\n");
+ ok(GetLastError() == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %u\n", GetLastError());
+
BeginPath(hdc);
MoveToEx(hdc, 95, 95, NULL);
LineTo(hdc, 95, 0);
--
1.5.6.5
More information about the wine-patches
mailing list