From: Bernhard Übelacker bernhardu@mailbox.org
--- dlls/gdiplus/imageattributes.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/dlls/gdiplus/imageattributes.c b/dlls/gdiplus/imageattributes.c index 349e52f5be9..e19687db39b 100644 --- a/dlls/gdiplus/imageattributes.c +++ b/dlls/gdiplus/imageattributes.c @@ -27,6 +27,13 @@
WINE_DEFAULT_DEBUG_CHANNEL(gdiplus);
+static inline int is_valid_ColorAdjustType(ColorAdjustType type) +{ + if (type >= ColorAdjustTypeDefault && type < ColorAdjustTypeCount) + return TRUE; + return FALSE; +} + GpStatus WINGDIPAPI GdipCloneImageAttributes(GDIPCONST GpImageAttributes *imageattr, GpImageAttributes **cloneImageattr) { @@ -117,7 +124,7 @@ GpStatus WINGDIPAPI GdipGetImageAttributesAdjustedPalette(GpImageAttributes *ima TRACE("(%p,%p,%u)\n", imageattr, palette, type);
if (!imageattr || !palette || !palette->Count || - type >= ColorAdjustTypeCount || type == ColorAdjustTypeDefault) + !is_valid_ColorAdjustType(type) || type == ColorAdjustTypeDefault) return InvalidParameter;
apply_image_attributes(imageattr, (LPBYTE)palette->Entries, palette->Count, 1, 0, @@ -131,7 +138,7 @@ GpStatus WINGDIPAPI GdipSetImageAttributesColorKeys(GpImageAttributes *imageattr { TRACE("(%p,%u,%i,%08lx,%08lx)\n", imageattr, type, enableFlag, colorLow, colorHigh);
- if(!imageattr || type >= ColorAdjustTypeCount) + if(!imageattr || !is_valid_ColorAdjustType(type)) return InvalidParameter;
imageattr->colorkeys[type].enabled = enableFlag; @@ -148,7 +155,7 @@ GpStatus WINGDIPAPI GdipSetImageAttributesColorMatrix(GpImageAttributes *imageat TRACE("(%p,%u,%i,%p,%p,%u)\n", imageattr, type, enableFlag, colorMatrix, grayMatrix, flags);
- if(!imageattr || type >= ColorAdjustTypeCount || flags > ColorMatrixFlagsAltGray) + if(!imageattr || !is_valid_ColorAdjustType(type) || flags > ColorMatrixFlagsAltGray) return InvalidParameter;
if (enableFlag) @@ -206,7 +213,7 @@ GpStatus WINGDIPAPI GdipSetImageAttributesGamma(GpImageAttributes *imageAttr, { TRACE("(%p,%u,%i,%0.2f)\n", imageAttr, type, enableFlag, gamma);
- if (!imageAttr || (enableFlag && gamma <= 0.0) || type >= ColorAdjustTypeCount) + if (!imageAttr || (enableFlag && gamma <= 0.0) || !is_valid_ColorAdjustType(type)) return InvalidParameter;
imageAttr->gamma_enabled[type] = enableFlag; @@ -220,7 +227,7 @@ GpStatus WINGDIPAPI GdipSetImageAttributesNoOp(GpImageAttributes *imageAttr, { TRACE("(%p,%u,%i)\n", imageAttr, type, enableFlag);
- if (type >= ColorAdjustTypeCount) + if (!is_valid_ColorAdjustType(type)) return InvalidParameter;
imageAttr->noop[type] = enableFlag ? IMAGEATTR_NOOP_SET : IMAGEATTR_NOOP_CLEAR; @@ -263,7 +270,7 @@ GpStatus WINGDIPAPI GdipSetImageAttributesRemapTable(GpImageAttributes *imageAtt
TRACE("(%p,%u,%i,%u,%p)\n", imageAttr, type, enableFlag, mapSize, map);
- if(!imageAttr || type >= ColorAdjustTypeCount) + if(!imageAttr || !is_valid_ColorAdjustType(type)) return InvalidParameter;
if (enableFlag) @@ -325,7 +332,7 @@ GpStatus WINGDIPAPI GdipResetImageAttributes(GpImageAttributes *imageAttr, { TRACE("(%p,%u)\n", imageAttr, type);
- if(!imageAttr || type >= ColorAdjustTypeCount) + if(!imageAttr || !is_valid_ColorAdjustType(type)) return InvalidParameter;
memset(&imageAttr->colormatrices[type], 0, sizeof(imageAttr->colormatrices[type]));