]> granicus.if.org Git - graphviz/commitdiff
Fixed: 'dereference before null check' in stack.c
authorErwin Janssen <erwinjanssen@outlook.com>
Sat, 19 Nov 2016 00:53:25 +0000 (01:53 +0100)
committerErwin Janssen <erwinjanssen@outlook.com>
Wed, 7 Dec 2016 13:52:39 +0000 (14:52 +0100)
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.

lib/rbtree/stack.c

index b269b937a12352c5024e0fc0d18598107ad3c320..1b93b9d99caf7d3b748ffac8c928e847c3ae5e82 100755 (executable)
@@ -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);