[3/4] gdiplus: check custom dash array for bad properties
Evan Stade
estade at gmail.com
Fri Jul 27 18:07:47 CDT 2007
Hi,
this fixes the issues that the last tests pointed out
dlls/gdiplus/pen.c | 12 ++++++++++++
dlls/gdiplus/tests/pen.c | 6 ++----
2 files changed, 14 insertions(+), 4 deletions(-)
--
Evan Stade
-------------- next part --------------
diff --git a/dlls/gdiplus/pen.c b/dlls/gdiplus/pen.c
index 7d7237b..b85f158 100644
--- a/dlls/gdiplus/pen.c
+++ b/dlls/gdiplus/pen.c
@@ -223,9 +223,21 @@ GpStatus WINGDIPAPI GdipSetPenCustomStar
GpStatus WINGDIPAPI GdipSetPenDashArray(GpPen *pen, GDIPCONST REAL *dash,
INT count)
{
+ INT i;
+ REAL sum = 0;
+
if(!pen || !dash)
return InvalidParameter;
+ for(i = 0; i < count; i++){
+ sum += dash[i];
+ if(dash[i] < 0.0)
+ return InvalidParameter;
+ }
+
+ if(sum == 0.0 && count)
+ return InvalidParameter;
+
GdipFree(pen->dashes);
pen->dashes = NULL;
diff --git a/dlls/gdiplus/tests/pen.c b/dlls/gdiplus/tests/pen.c
index 3fede54..fc792a6 100644
--- a/dlls/gdiplus/tests/pen.c
+++ b/dlls/gdiplus/tests/pen.c
@@ -176,12 +176,10 @@ static void test_dasharray(void)
/* Some invalid array values. */
status = GdipSetPenDashArray(pen, &dashes[7], 5);
- todo_wine
- expect(InvalidParameter, status);
+ expect(InvalidParameter, status);
dashes[9] = -1.0;
status = GdipSetPenDashArray(pen, &dashes[7], 5);
- todo_wine
- expect(InvalidParameter, status);
+ expect(InvalidParameter, status);
/* Try to set with count = 0. */
GdipSetPenDashStyle(pen, DashStyleDot);
--
1.4.1
More information about the wine-patches
mailing list