aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/core/SkWriter32.cpp1
-rw-r--r--tests/Writer32Test.cpp10
2 files changed, 10 insertions, 1 deletions
diff --git a/src/core/SkWriter32.cpp b/src/core/SkWriter32.cpp
index ca21c5ad6d..e5befbafb4 100644
--- a/src/core/SkWriter32.cpp
+++ b/src/core/SkWriter32.cpp
@@ -61,7 +61,6 @@ SkWriter32::Block* SkWriter32::doReserve(size_t size) {
fHead = fTail = block = Block::Create(SkMax32(size, fMinSize));
SkASSERT(0 == fWrittenBeforeLastBlock);
} else {
- SkASSERT(fSize > 0);
fWrittenBeforeLastBlock = fSize;
fTail = Block::Create(SkMax32(size, fMinSize));
diff --git a/tests/Writer32Test.cpp b/tests/Writer32Test.cpp
index 194164dd1c..fd232fc4d0 100644
--- a/tests/Writer32Test.cpp
+++ b/tests/Writer32Test.cpp
@@ -21,6 +21,15 @@ static void check_contents(skiatest::Reporter* reporter, const SkWriter32& write
REPORTER_ASSERT(reporter, !memcmp(storage.get(), expected, size));
}
+
+static void test_reserve(skiatest::Reporter* reporter) {
+ // There used to be a bug where we'd assert your first reservation had to
+ // fit in external storage if you used it. This would crash in debug mode.
+ uint8_t storage[4];
+ SkWriter32 writer(0, storage, sizeof(storage));
+ writer.reserve(40);
+}
+
static void test_string_null(skiatest::Reporter* reporter) {
uint8_t storage[8];
SkWriter32 writer(0, storage, sizeof(storage));
@@ -238,6 +247,7 @@ static void Tests(skiatest::Reporter* reporter) {
testWritePad(reporter, &writer);
}
+ test_reserve(reporter);
test_string_null(reporter);
test_ptr(reporter);
test_rewind(reporter);