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
diff --git a/src/core/SkPictureRecord.cpp b/src/core/SkPictureRecord.cpp
index b908670..5c00ab9 100644
--- a/src/core/SkPictureRecord.cpp
+++ b/src/core/SkPictureRecord.cpp
@@ -49,18 +49,20 @@
}
void SkPictureRecord::restore() {
-
- // 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();
+ // 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();
addDraw(RESTORE);
validate();