aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkReadBuffer.cpp
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2017-12-07 12:48:38 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-12-07 19:29:31 +0000
commitb681972e79993e37adb9de9666cc9064b528db8b (patch)
tree6aa437cd1157450ac7a8b15864c7ee9076b7725c /src/core/SkReadBuffer.cpp
parent75d55d3d4509669009d6202cab23ce9320fe8577 (diff)
use serialprocs for typefaces
Bug: skia: Change-Id: Ibf59a0fdcf68e8555bd4241e9473e733f6a30993 Reviewed-on: https://skia-review.googlesource.com/81840 Reviewed-by: Florin Malita <fmalita@chromium.org> Reviewed-by: Mike Klein <mtklein@chromium.org> Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'src/core/SkReadBuffer.cpp')
-rw-r--r--src/core/SkReadBuffer.cpp22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/core/SkReadBuffer.cpp b/src/core/SkReadBuffer.cpp
index 78071ee227..9fcee54c9f 100644
--- a/src/core/SkReadBuffer.cpp
+++ b/src/core/SkReadBuffer.cpp
@@ -374,12 +374,26 @@ sk_sp<SkTypeface> SkReadBuffer::readTypeface() {
return sk_ref_sp(fInflator->getTypeface(this->read32()));
}
- uint32_t index = this->readUInt();
- if (0 == index || index > (unsigned)fTFCount) {
+ // Read 32 bits (signed)
+ // 0 -- failure
+ // >0 -- index
+ // <0 -- custom (serial procs) : negative size in bytes
+
+ int32_t index = this->readUInt();
+ if (index == 0) {
return nullptr;
- } else {
- SkASSERT(fTFArray);
+ } else if (index > 0) {
+ if (index > fTFCount) {
+ return nullptr;
+ }
return sk_ref_sp(fTFArray[index - 1]);
+ } else { // custom
+ size_t size = -index;
+ const void* data = this->skip(size);
+ if (!data) {
+ return nullptr;
+ }
+ return fProcs.fTypefaceProc(data, size, fProcs.fTypefaceCtx);
}
}