diff options
author | reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2009-07-09 15:20:25 +0000 |
---|---|---|
committer | reed@android.com <reed@android.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2009-07-09 15:20:25 +0000 |
commit | b4e22d62da422f3599ef9bd5091c5f4b7709d27e (patch) | |
tree | 945eaf81f9a7c179bec50c48bd3381909c0f6273 /src | |
parent | 1134426f6b1c4130e8dbe4c38a4aa976fbb18b4b (diff) |
check for underflow in restore() during picture record, and ignore it
git-svn-id: http://skia.googlecode.com/svn/trunk@262 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkPictureRecord.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp index b908670baf..5c00ab9bfe 100644 --- a/src/core/SkPictureRecord.cpp +++ b/src/core/SkPictureRecord.cpp @@ -49,18 +49,20 @@ int SkPictureRecord::saveLayer(const SkRect* bounds, const SkPaint* paint, } void SkPictureRecord::restore() { - + // check for underflow + if (fRestoreOffsetStack.count() == 0) { + return; + } + // patch up the clip offsets - { - uint32_t restoreOffset = (uint32_t)fWriter.size(); - uint32_t offset = fRestoreOffsetStack.top(); - while (offset) { - uint32_t* peek = fWriter.peek32(offset); - offset = *peek; - *peek = restoreOffset; - } - fRestoreOffsetStack.pop(); + uint32_t restoreOffset = (uint32_t)fWriter.size(); + uint32_t offset = fRestoreOffsetStack.top(); + while (offset) { + uint32_t* peek = fWriter.peek32(offset); + offset = *peek; + *peek = restoreOffset; } + fRestoreOffsetStack.pop(); addDraw(RESTORE); validate(); |