aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/SkColorSpaceXform_skcms.cpp5
-rw-r--r--src/core/SkColorSpace_ICC.cpp11
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);