Vincent Povirk : gdiplus: Improve GdipFillRectangles parameter validation.
Alexandre Julliard
julliard at winehq.org
Thu Feb 20 10:08:10 CST 2014
Module: wine
Branch: master
Commit: 78459aea0dcce1e5b7dd9d30b1e516646f33722d
URL: http://source.winehq.org/git/wine.git/?a=commit;h=78459aea0dcce1e5b7dd9d30b1e516646f33722d
Author: Vincent Povirk <vincent at codeweavers.com>
Date: Wed Feb 19 15:16:48 2014 -0600
gdiplus: Improve GdipFillRectangles parameter validation.
---
dlls/gdiplus/graphics.c | 2 +-
dlls/gdiplus/tests/graphics.c | 47 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 48 insertions(+), 1 deletion(-)
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c
index 2608bf4..1f01b82 100644
--- a/dlls/gdiplus/graphics.c
+++ b/dlls/gdiplus/graphics.c
@@ -3747,7 +3747,7 @@ GpStatus WINGDIPAPI GdipFillRectangles(GpGraphics *graphics, GpBrush *brush, GDI
TRACE("(%p, %p, %p, %d)\n", graphics, brush, rects, count);
- if(!rects)
+ if(!graphics || !brush || !rects || count <= 0)
return InvalidParameter;
if (graphics->image && graphics->image->type == ImageTypeMetafile)
diff --git a/dlls/gdiplus/tests/graphics.c b/dlls/gdiplus/tests/graphics.c
index 4d74081..9fb1347 100644
--- a/dlls/gdiplus/tests/graphics.c
+++ b/dlls/gdiplus/tests/graphics.c
@@ -5493,6 +5493,52 @@ static void test_clipping_2(void)
DeleteDC(hdc);
}
+
+static void test_GdipFillRectangles(void)
+{
+ GpStatus status;
+ GpGraphics *graphics = NULL;
+ GpBrush *brush = NULL;
+ HDC hdc = GetDC( hwnd );
+ GpRectF rects[2] = {{0,0,10,10}, {10,10,10,10}};
+
+ ok(hdc != NULL, "Expected HDC to be initialized\n");
+
+ status = GdipCreateFromHDC(hdc, &graphics);
+ expect(Ok, status);
+ ok(graphics != NULL, "Expected graphics to be initialized\n");
+
+ status = GdipCreateSolidFill((ARGB)0xffff00ff, (GpSolidFill**)&brush);
+ expect(Ok, status);
+ ok(brush != NULL, "Expected brush to be initialized\n");
+
+ status = GdipFillRectangles(NULL, brush, rects, 2);
+ expect(InvalidParameter, status);
+
+ status = GdipFillRectangles(graphics, NULL, rects, 2);
+ expect(InvalidParameter, status);
+
+ status = GdipFillRectangles(graphics, brush, NULL, 2);
+ expect(InvalidParameter, status);
+
+ status = GdipFillRectangles(graphics, brush, rects, 0);
+ expect(InvalidParameter, status);
+
+ status = GdipFillRectangles(graphics, brush, rects, -1);
+ expect(InvalidParameter, status);
+
+ status = GdipFillRectangles(graphics, brush, rects, 1);
+ expect(Ok, status);
+
+ status = GdipFillRectangles(graphics, brush, rects, 2);
+ expect(Ok, status);
+
+ GdipDeleteBrush(brush);
+ GdipDeleteGraphics(graphics);
+
+ ReleaseDC(hwnd, hdc);
+}
+
START_TEST(graphics)
{
struct GdiplusStartupInput gdiplusStartupInput;
@@ -5563,6 +5609,7 @@ START_TEST(graphics)
test_getdc_scaled();
test_alpha_hdc();
test_bitmapfromgraphics();
+ test_GdipFillRectangles();
GdiplusShutdown(gdiplusToken);
DestroyWindow( hwnd );
More information about the wine-cvs
mailing list