From fd9972c1a2a630f3800ba4c73dd16cf03628cd50 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Wed, 26 Mar 2003 16:58:33 +0200 Subject: [PATCH] When data stack grew larger than two blocks, t_pop()ing crashed when trying to free extra blocks. --HG-- branch : HEAD --- src/lib/data-stack.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/data-stack.c b/src/lib/data-stack.c index 54c6ed353d..15a8303972 100644 --- a/src/lib/data-stack.c +++ b/src/lib/data-stack.c @@ -121,9 +121,13 @@ unsigned int t_push(void) static void free_blocks(struct stack_block *block) { + struct stack_block *next; + /* free all the blocks, except if any of them is bigger than unused_block, replace it */ while (block != NULL) { + next = block->next; + if (unused_block == NULL || block->size > unused_block->size) { free(unused_block); unused_block = block; @@ -131,7 +135,7 @@ static void free_blocks(struct stack_block *block) free(block); } - block = block->next; + block = next; } } -- 2.47.3