Skip to content
Permalink
Browse files
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.
  • Loading branch information
bblough committed May 17, 2018
1 parent 05577ea commit 035dbdda1a68418f5f0d025568b865750a19a642
Showing 1 changed file with 4 additions and 1 deletion.
@@ -50,7 +50,10 @@ guththila_stack_un_init(
const axutil_env_t * env)
{
if(stack->data)
{
AXIS2_FREE(env->allocator, stack->data);
stack->data = NULL;
}
}

void *GUTHTHILA_CALL
@@ -110,7 +113,7 @@ guththila_stack_del_top(
{
if(stack->top > 0)
{
AXIS2_FREE(env->allocator, stack->data[stack->top]);
stack->data[stack->top--] = NULL;
return GUTHTHILA_SUCCESS;
}
return GUTHTHILA_FAILURE;

0 comments on commit 035dbdd

Please sign in to comment.