If you give SkWriter32 external storage but that external storage is too small
for the first reservation you make, you'll hit an assert in debug mode.

I think the answer is to simply remove the SkASSERT.  Added a test.

BUG=
R=reed@google.com

Review URL: https://codereview.chromium.org/23646007

git-svn-id: http://skia.googlecode.com/svn/trunk@11062 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
mtklein@google.com 2013-09-03 18:07:01 +00:00
Родитель c6168f2b2c
Коммит 8b4ba63735
2 изменённых файлов: 10 добавлений и 1 удалений

Просмотреть файл

@ -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));

Просмотреть файл

@ -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);