fixing bug in sexp_destroy_context

We need to grab a reference to the context heap before sweeping, in
case sweeping overwrites the heap reference.
This commit is contained in:
Alex Shinn 2010-03-09 20:23:29 +09:00
parent 95e0b0bb31
commit 171966956f

2
sexp.c
View file

@ -293,8 +293,8 @@ void sexp_destroy_context (sexp ctx) {
sexp_heap heap, tmp;
size_t sum_freed;
if (sexp_context_heap(ctx)) {
sexp_sweep(ctx, &sum_freed); /* sweep w/o mark to run finalizers */
heap = sexp_context_heap(ctx);
sexp_sweep(ctx, &sum_freed); /* sweep w/o mark to run finalizers */
sexp_context_heap(ctx) = NULL;
for ( ; heap; heap=tmp) {
tmp = heap->next;