Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Unified Diff: src/core/SkTextBlob.cpp

Issue 1388543005: Validate text blob runs after SkTextBlob construction. (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: now actually tested Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkTextBlob.cpp
diff --git a/src/core/SkTextBlob.cpp b/src/core/SkTextBlob.cpp
index 68784f48b52c6ac0385c3631b0c6c9035e9adae7..a49ff251016a90768e52b77bf1d5847bc916e096 100644
--- a/src/core/SkTextBlob.cpp
+++ b/src/core/SkTextBlob.cpp
@@ -157,7 +157,7 @@ public:
+ StorageSize(run->glyphCount(), run->positioning()));
}
- void validate(uint8_t* storageTop) const {
+ void validate(const uint8_t* storageTop) const {
SkASSERT(kRunRecordMagic == fMagic);
SkASSERT((uint8_t*)Next(this) <= storageTop);
SkASSERT(glyphBuffer() + fCount <= (uint16_t*)posBuffer());
@@ -583,21 +583,20 @@ const SkTextBlob* SkTextBlobBuilder::build() {
fStorage.realloc(fStorageUsed);
}
+ const SkTextBlob* blob = new (fStorage.detach()) SkTextBlob(fRunCount, fBounds);
+ SkDEBUGCODE(const_cast<SkTextBlob*>(blob)->fStorageSize = fStorageSize;)
+
SkDEBUGCODE(
size_t validateSize = sizeof(SkTextBlob);
- const SkTextBlob::RunRecord* run =
- SkTextBlob::RunRecord::First(reinterpret_cast<const SkTextBlob*>(fStorage.get()));
+ const SkTextBlob::RunRecord* run = SkTextBlob::RunRecord::First(blob);
for (int i = 0; i < fRunCount; ++i) {
validateSize += SkTextBlob::RunRecord::StorageSize(run->fCount, run->fPositioning);
- run->validate(fStorage.get() + fStorageUsed);
+ run->validate(reinterpret_cast<const uint8_t*>(blob) + fStorageUsed);
run = SkTextBlob::RunRecord::Next(run);
}
SkASSERT(validateSize == fStorageUsed);
)
- const SkTextBlob* blob = new (fStorage.detach()) SkTextBlob(fRunCount, fBounds);
- SkDEBUGCODE(const_cast<SkTextBlob*>(blob)->fStorageSize = fStorageSize;)
-
fStorageUsed = 0;
fStorageSize = 0;
fRunCount = 0;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698