From: Erwin Janssen Date: Sat, 19 Nov 2016 00:53:25 +0000 (+0100) Subject: Fixed: 'dereference before null check' in stack.c X-Git-Tag: 2.42.0~229^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=08da710165f71c5ec404d6e7232665927668131b;p=graphviz Fixed: 'dereference before null check' in stack.c The pointer `theStack` is dereferenced before the if statement that checks whether `theStack` is null. This is fixed by placing the variable declarations in the if statement. --- diff --git a/lib/rbtree/stack.c b/lib/rbtree/stack.c index b269b937a..1b93b9d99 100755 --- a/lib/rbtree/stack.c +++ b/lib/rbtree/stack.c @@ -69,10 +69,9 @@ DATA_TYPE StackPop(stk_stack * theStack) { } void StackDestroy(stk_stack * theStack,void DestFunc(void * a)) { - stk_stack_node * x=theStack->top; - stk_stack_node * y; - if(theStack) { + stk_stack_node * x=theStack->top; + stk_stack_node * y; while(x) { y=x->next; DestFunc(x->info);