Fix guththila stack issues
guththila_stack_push allocates memory is chunks of stack->max or
stack->max * 2, however guththila_stack_del_top tries to free individual data
elements, leading to memory errors. Changed del_top function to remove
value from stack but not attempt to free the memory (which will be freed
when stack_un_init or stack_free is called).
Also, in guththila_stack_un_init, set stack_data = NULL after freeing, to
avoid possible double free if stack_free is inadvertently called after
stack_un_init.
diff --git a/guththila/src/guththila_stack.c b/guththila/src/guththila_stack.c
index fd629c1..e5b229d 100644
--- a/guththila/src/guththila_stack.c
+++ b/guththila/src/guththila_stack.c
@@ -50,7 +50,10 @@
const axutil_env_t * env)
{
if(stack->data)
+ {
AXIS2_FREE(env->allocator, stack->data);
+ stack->data = NULL;
+ }
}
void *GUTHTHILA_CALL
@@ -110,7 +113,7 @@
{
if(stack->top > 0)
{
- AXIS2_FREE(env->allocator, stack->data[stack->top]);
+ stack->data[stack->top--] = NULL;
return GUTHTHILA_SUCCESS;
}
return GUTHTHILA_FAILURE;