diff options
author | Mike Klein <mtklein@chromium.org> | 2018-05-07 14:50:37 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-05-07 19:18:37 +0000 |
commit | ecac36e6b991d4e65a60d6a08fa23a35c533d0d5 (patch) | |
tree | 2c931f7379c8f832e508c4090fcf01ebd118cd03 /src/core | |
parent | 1f5cd6cc7fa2a1c8253e5d11626f2a73dc313c25 (diff) |
make SkColorSpace::MakeICC strict as skcms
We do this somewhat trivially by calling skcms_Parse()
and failing if it fails.
This will help keep us sane while we work to remove
SkColorSpace::MakeICC().
Change-Id: Icb1bc1a088083e181f46465dbb3a530f0e004193
Reviewed-on: https://skia-review.googlesource.com/126510
Commit-Queue: Mike Klein <mtklein@chromium.org>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: Mike Klein <mtklein@chromium.org>
Reviewed-by: Brian Osman <brianosman@google.com>
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/SkColorSpaceXform_skcms.cpp | 5 | ||||
-rw-r--r-- | src/core/SkColorSpace_ICC.cpp | 11 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/core/SkColorSpaceXform_skcms.cpp b/src/core/SkColorSpaceXform_skcms.cpp index d9143e828e..549db8f1a6 100644 --- a/src/core/SkColorSpaceXform_skcms.cpp +++ b/src/core/SkColorSpaceXform_skcms.cpp @@ -159,3 +159,8 @@ sk_sp<SkColorSpace> SkColorSpace::Make(const skcms_ICCProfile* profile) { return SkColorSpace::MakeRGB(skia_tf, toXYZD50); } + +bool skcms_can_parse(const void* buf, size_t len) { + skcms_ICCProfile p; + return skcms_Parse(buf, len, &p); +} diff --git a/src/core/SkColorSpace_ICC.cpp b/src/core/SkColorSpace_ICC.cpp index 6a3076dc1b..88b9dfeb3c 100644 --- a/src/core/SkColorSpace_ICC.cpp +++ b/src/core/SkColorSpace_ICC.cpp @@ -15,6 +15,12 @@ #include "SkICCPriv.h" #include "SkTemplates.h" +#if defined(SK_USE_SKCMS) + bool skcms_can_parse(const void*, size_t); +#else + static bool skcms_can_parse(const void*, size_t) { return true; } +#endif + #define return_if_false(pred, msg) \ do { \ if (!(pred)) { \ @@ -1482,6 +1488,11 @@ sk_sp<SkColorSpace> SkColorSpace::MakeICC(const void* input, size_t len) { return_null("Data is null or not large enough to contain an ICC profile"); } + // Make sure we're at least as strict as skcms_Parse(). + if (!skcms_can_parse(input, len)) { + return nullptr; + } + // Create our own copy of the input. void* memory = sk_malloc_throw(len); memcpy(memory, input, len); |