gdiplus: Check custom dash array for bad properties.

This commit is contained in:
Evan Stade 2007-07-27 16:07:47 -07:00 committed by Alexandre Julliard
parent a35206e08e
commit b6b7e915c3
2 changed files with 14 additions and 4 deletions

View File

@ -223,9 +223,21 @@ GpStatus WINGDIPAPI GdipSetPenCustomStartCap(GpPen *pen, GpCustomLineCap* custom
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;

View File

@ -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);