Check enum values in SkDisplacementMapEffect's CreateProc

Bug: skia:5635
Change-Id: Iaa01d2207916d0e2a2e2623f124b2b4023b51b1b
Reviewed-on: https://skia-review.googlesource.com/99204
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Mike Reed <reed@google.com>
This commit is contained in:
Robert Phillips 2018-01-24 14:39:38 -05:00 committed by Skia Commit-Bot
parent dc3d7fcbb8
commit b0ae566b23
2 changed files with 17 additions and 3 deletions

View File

@ -17,7 +17,9 @@ public:
kR_ChannelSelectorType,
kG_ChannelSelectorType,
kB_ChannelSelectorType,
kA_ChannelSelectorType
kA_ChannelSelectorType,
kLast_ChannelSelectorType = kA_ChannelSelectorType
};
~SkDisplacementMapEffect() override;

View File

@ -11,6 +11,7 @@
#include "SkColorSpaceXformer.h"
#include "SkImageFilterPriv.h"
#include "SkReadBuffer.h"
#include "SkSafeRange.h"
#include "SkSpecialImage.h"
#include "SkWriteBuffer.h"
#include "SkUnPreMultiply.h"
@ -146,10 +147,21 @@ SkDisplacementMapEffect::~SkDisplacementMapEffect() {
}
sk_sp<SkFlattenable> SkDisplacementMapEffect::CreateProc(SkReadBuffer& buffer) {
SkSafeRange safe;
SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 2);
ChannelSelectorType xsel = (ChannelSelectorType)buffer.readInt();
ChannelSelectorType ysel = (ChannelSelectorType)buffer.readInt();
ChannelSelectorType xsel = safe.checkLE<ChannelSelectorType>(buffer.readInt(),
kLast_ChannelSelectorType);
ChannelSelectorType ysel = safe.checkLE<ChannelSelectorType>(buffer.readInt(),
kLast_ChannelSelectorType);
SkScalar scale = buffer.readScalar();
if (!buffer.validate(safe)) {
return nullptr;
}
return Make(xsel, ysel, scale,
common.getInput(0), common.getInput(1),
&common.cropRect());