aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Writer32Test.cpp
diff options
context:
space:
mode:
authorGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-08-31 20:17:56 +0000
committerGravatar reed@google.com <reed@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>2012-08-31 20:17:56 +0000
commitd7e27822030b5ab7729e32c6d29227210dfe88ab (patch)
tree322f4d7b38bbd7f24888b05f47f00ecbc9b6ff66 /tests/Writer32Test.cpp
parent6bc8cf8f647002909bd4e437a442ec69c98028f6 (diff)
truncate our llist w/ null during rewind.
git-svn-id: http://skia.googlecode.com/svn/trunk@5375 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'tests/Writer32Test.cpp')
-rw-r--r--tests/Writer32Test.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/Writer32Test.cpp b/tests/Writer32Test.cpp
index 21c11c16c6..4715f7a613 100644
--- a/tests/Writer32Test.cpp
+++ b/tests/Writer32Test.cpp
@@ -37,6 +37,20 @@ static void test_rewind(skiatest::Reporter* reporter) {
REPORTER_ASSERT(reporter, sizeof(array) == writer.bytesWritten());
array[2] = 3;
check_contents(reporter, writer, array, sizeof(array));
+
+ // test rewinding past allocated chunks. This used to crash because we
+ // didn't truncate our link-list after freeing trailing blocks
+ {
+ SkWriter32 writer(64);
+ for (int i = 0; i < 100; ++i) {
+ writer.writeInt(i);
+ }
+ REPORTER_ASSERT(reporter, 100*4 == writer.bytesWritten());
+ for (int j = 100*4; j >= 0; j -= 16) {
+ writer.rewindToOffset(j);
+ }
+ REPORTER_ASSERT(reporter, writer.bytesWritten() < 16);
+ }
}
static void test_ptr(skiatest::Reporter* reporter) {