aboutsummaryrefslogtreecommitdiff
path: root/libs/libc/stack.c
diff options
context:
space:
mode:
Diffstat (limited to 'libs/libc/stack.c')
-rw-r--r--libs/libc/stack.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/libs/libc/stack.c b/libs/libc/stack.c
index 6f16709..81c76a2 100644
--- a/libs/libc/stack.c
+++ b/libs/libc/stack.c
@@ -22,11 +22,12 @@ void stack_destroy(struct stack *stack)
break;
}
iterator = iterator->prev;
- free(iterator->next);
+
+ if (iterator && iterator->prev)
+ free(iterator->prev);
}
- stack->tail = NULL;
+ memset(stack, 0, sizeof(*stack));
free(stack);
- stack = NULL;
}
static struct stack_node *stack_new_node(void)