aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkTextBlob.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/SkTextBlob.cpp')
-rw-r--r--src/core/SkTextBlob.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/core/SkTextBlob.cpp b/src/core/SkTextBlob.cpp
index c6325dfbc5..4a029287b0 100644
--- a/src/core/SkTextBlob.cpp
+++ b/src/core/SkTextBlob.cpp
@@ -596,10 +596,13 @@ bool SkTextBlobBuilder::mergeRun(const SkPaint &font, SkTextBlob::GlyphPositioni
void SkTextBlobBuilder::allocInternal(const SkPaint &font,
SkTextBlob::GlyphPositioning positioning,
- int count, int textSize, SkPoint offset, const SkRect* bounds) {
- SkASSERT(count > 0);
- SkASSERT(textSize >= 0);
- SkASSERT(SkPaint::kGlyphID_TextEncoding == font.getTextEncoding());
+ int count, int textSize, SkPoint offset,
+ const SkRect* bounds) {
+ if (count <= 0 || textSize < 0 || font.getTextEncoding() != SkPaint::kGlyphID_TextEncoding) {
+ fCurrentRunBuffer = { nullptr, nullptr, nullptr, nullptr };
+ return;
+ }
+
if (textSize != 0 || !this->mergeRun(font, positioning, count, offset)) {
this->updateDeferredBounds();
@@ -772,13 +775,20 @@ sk_sp<SkTextBlob> SkTextBlob::MakeFromBuffer(SkReadBuffer& reader) {
if (glyphCount <= 0 || pos > kFull_Positioning) {
return nullptr;
}
- uint32_t textSize = pe.extended ? (uint32_t)reader.read32() : 0;
+ int textSize = pe.extended ? reader.read32() : 0;
+ if (textSize < 0) {
+ return nullptr;
+ }
SkPoint offset;
reader.readPoint(&offset);
SkPaint font;
reader.readPaint(&font);
+ if (!reader.isValid()) {
+ return nullptr;
+ }
+
const SkTextBlobBuilder::RunBuffer* buf = nullptr;
switch (pos) {
case kDefault_Positioning:
@@ -850,7 +860,8 @@ public:
{}
sk_sp<SkTypeface> readTypeface() override {
- return fResolverProc(this->read32(), fResolverCtx);
+ auto id = this->readUInt();
+ return this->isValid() ? fResolverProc(id, fResolverCtx) : nullptr;
}
SkTypefaceResolverProc fResolverProc;