aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/SkWriter32.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/SkWriter32.cpp')
-rw-r--r--src/core/SkWriter32.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/core/SkWriter32.cpp b/src/core/SkWriter32.cpp
index d2c85876a9..3ae6a0775c 100644
--- a/src/core/SkWriter32.cpp
+++ b/src/core/SkWriter32.cpp
@@ -161,6 +161,9 @@ uint32_t* SkWriter32::peek32(size_t offset) {
}
void SkWriter32::rewindToOffset(size_t offset) {
+ if (offset >= fSize) {
+ return;
+ }
if (0 == offset) {
this->reset(NULL, 0);
return;
@@ -179,19 +182,20 @@ void SkWriter32::rewindToOffset(size_t offset) {
// Similar to peek32, except that we free up any following blocks
Block* block = fHead;
SkASSERT(NULL != block);
-
while (offset >= block->fAllocatedSoFar) {
offset -= block->fAllocatedSoFar;
block = block->fNext;
SkASSERT(NULL != block);
}
- fTail = block;
+ // update the size on the "last" block
block->fAllocatedSoFar = offset;
-
- // free up any following blocks
- SkASSERT(block);
- block = block->fNext;
+ // end our list
+ fTail = block;
+ Block* next = block->fNext;
+ block->fNext = NULL;
+ // free up any trailing blocks
+ block = next;
while (block) {
Block* next = block->fNext;
sk_free(block);