aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar Mike Reed <reed@google.com>2017-07-26 18:34:51 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-07-26 18:35:01 +0000
commita4ce4b1f6bef22e7ca5c7a952197fc2bc70923fc (patch)
tree600f281c5b3f3650a4a1e5530efe7e024e5bd98c /tests
parent737149126df1a44bc80393cfe35017bab983c357 (diff)
Revert "Fix SkPathRef deserialization malloc crash"
This reverts commit df6660f64e4d915de7471c3daa67f9b68037ff3f. Reason for revert: crashing dm on android and windows Original change's description: > Fix SkPathRef deserialization malloc crash > > If the path says it has more points/verbs/etc than the buffer could > be holding, then resetToSize could try to allocate something huge > and crash. > > Change-Id: I40e8db87e4f61abb23217281ab0365c6af222fa3 > Reviewed-on: https://skia-review.googlesource.com/24802 > Reviewed-by: Mike Reed <reed@google.com> > Commit-Queue: Mike Reed <reed@google.com> TBR=bungeman@google.com,reed@google.com,enne@chromium.org Change-Id: I06fa89c05b785652b097ae04e7ebc001a7c176b2 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://skia-review.googlesource.com/26944 Reviewed-by: Mike Reed <reed@google.com> Commit-Queue: Mike Reed <reed@google.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/PathTest.cpp57
1 files changed, 0 insertions, 57 deletions
diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp
index e4edb76627..117da5bdeb 100644
--- a/tests/PathTest.cpp
+++ b/tests/PathTest.cpp
@@ -4775,60 +4775,3 @@ DEF_TEST(skbug_6450, r) {
orr.setRectRadii(ro, rdo);
SkMakeNullCanvas()->drawDRRect(orr, irr, SkPaint());
}
-
-DEF_TEST(PathRefSerialization, reporter) {
- SkPath path;
- const size_t numMoves = 5;
- const size_t numConics = 7;
- const size_t numPoints = numMoves + 2 * numConics;
- const size_t numVerbs = numMoves + numConics;
- for (size_t i = 0; i < numMoves; ++i) path.moveTo(1, 2);
- for (size_t i = 0; i < numConics; ++i) path.conicTo(1, 2, 3, 4, 5);
- REPORTER_ASSERT(reporter, path.countPoints() == numPoints);
- REPORTER_ASSERT(reporter, path.countVerbs() == numVerbs);
-
- // Verify that path serializes/deserializes properly.
- SkWriter32 writer;
- writer.writePath(path);
- size_t bytesWritten = writer.bytesWritten();
- SkAutoMalloc storage(bytesWritten);
- writer.flatten(storage.get());
- {
- SkPath readBack;
- REPORTER_ASSERT(reporter, readBack != path);
- size_t bytesRead = readBack.readFromMemory(storage.get(), bytesWritten);
- REPORTER_ASSERT(reporter, bytesRead == bytesWritten);
- REPORTER_ASSERT(reporter, readBack == path);
- }
-
- // uint32_t[] offset into serialized path.
- const size_t verbCountOffset = 4;
- const size_t pointCountOffset = 5;
- const size_t conicCountOffset = 6;
-
- // Verify that this test is changing the right values.
- int* writtenValues = static_cast<int*>(storage.get());
- REPORTER_ASSERT(reporter, writtenValues[verbCountOffset] == numVerbs);
- REPORTER_ASSERT(reporter, writtenValues[pointCountOffset] == numPoints);
- REPORTER_ASSERT(reporter, writtenValues[conicCountOffset] == numConics);
-
- // Too many verbs, points, or conics fails to deserialize silently.
- const int tooManyObjects = INT_MAX;
- size_t offsets[] = {verbCountOffset, pointCountOffset, conicCountOffset};
- for (size_t i = 0; i < 3; ++i) {
- SkAutoMalloc storage_copy(bytesWritten);
- memcpy(storage_copy.get(), storage.get(), bytesWritten);
- static_cast<int*>(storage_copy.get())[offsets[i]] = tooManyObjects;
- SkPath readBack;
- size_t bytesRead = readBack.readFromMemory(storage_copy.get(), bytesWritten);
- REPORTER_ASSERT(reporter, !bytesRead);
- }
-
- // One less byte (rounded down to alignment) than was written will also
- // fail to be deserialized.
- {
- SkPath readBack;
- size_t bytesRead = readBack.readFromMemory(storage.get(), bytesWritten - 4);
- REPORTER_ASSERT(reporter, !bytesRead);
- }
-}