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
This commit is contained in:
reed@android.com 2009-07-09 15:20:25 +00:00
parent 1134426f6b
commit b4e22d62da

View File

@ -49,18 +49,20 @@ int SkPictureRecord::saveLayer(const SkRect* bounds, const SkPaint* paint,
}
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();