diff --git a/js/src/ds/LifoAlloc.cpp b/js/src/ds/LifoAlloc.cpp index 6ee8e49d9c78..384daae559d7 100644 --- a/js/src/ds/LifoAlloc.cpp +++ b/js/src/ds/LifoAlloc.cpp @@ -143,8 +143,12 @@ LifoAlloc::freeUnused() } /* Free all chunks after |latest|. */ - for (BumpChunk *victim = latest->next(); victim; victim = victim->next()) + BumpChunk *it = latest->next(); + while (it) { + BumpChunk *victim = it; + it = it->next(); BumpChunk::delete_(victim); + } latest->setNext(NULL); }