aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/effects/SkHighContrastFilter.cpp
diff options
context:
space:
mode:
authorGravatar Robert Phillips <robertphillips@google.com>2018-01-24 14:46:38 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-01-24 21:54:30 +0000
commita83d0132baa681339e7e7f018dbdcc4051caae3d (patch)
treee9be321a81d04cc28a5c388a6f8a8f76ee5a1224 /src/effects/SkHighContrastFilter.cpp
parent548d387ab935349edd03149502fff8ebe467b5b0 (diff)
Misc guarding of enums in ImageFilter CreateProcs
Change-Id: I51886aaf2a4670f46ca489b2369dc00e60403c75 Reviewed-on: https://skia-review.googlesource.com/99328 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/effects/SkHighContrastFilter.cpp')
-rw-r--r--src/effects/SkHighContrastFilter.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/effects/SkHighContrastFilter.cpp b/src/effects/SkHighContrastFilter.cpp
index 9df04c110b..69cbcd7a9c 100644
--- a/src/effects/SkHighContrastFilter.cpp
+++ b/src/effects/SkHighContrastFilter.cpp
@@ -9,6 +9,7 @@
#include "SkPM4f.h"
#include "SkArenaAlloc.h"
#include "SkRasterPipeline.h"
+#include "SkSafeRange.h"
#include "SkReadBuffer.h"
#include "SkString.h"
#include "SkWriteBuffer.h"
@@ -141,10 +142,17 @@ void SkHighContrast_Filter::flatten(SkWriteBuffer& buffer) const {
}
sk_sp<SkFlattenable> SkHighContrast_Filter::CreateProc(SkReadBuffer& buffer) {
+ SkSafeRange safe;
+
SkHighContrastConfig config;
config.fGrayscale = buffer.readBool();
- config.fInvertStyle = static_cast<InvertStyle>(buffer.readInt());
+ config.fInvertStyle = safe.checkLE<InvertStyle>(buffer.readInt(), InvertStyle::kLast);
config.fContrast = buffer.readScalar();
+
+ if (!buffer.validate(safe)) {
+ return nullptr;
+ }
+
return SkHighContrastFilter::Make(config);
}