Browse Source

avl: guard against theoretical null pointer dereference

clang-10 analyzer reports following:

 avl.c:671:25: warning: Access to field 'parent' results in a dereference of a null pointer (loaded from field 'right')
     node->right->parent = parent;
           ~~~~~         ^

Which seems to be impossible to trigger via exported AVL public API, but
it could be probably trigerred by fiddling with the AVL tree node struct
members manually as they are exposed.

Signed-off-by: Petr Štetiar <ynezz@true.cz>
master
Petr Štetiar 1 year ago
parent
commit
9b6ede0e53
1 changed files with 2 additions and 0 deletions
  1. +2
    -0
      avl.c

+ 2
- 0
avl.c View File

@ -45,6 +45,7 @@
#include <string.h>
#include "avl.h"
#include "assert.h"
#include "list.h"
/**
@ -668,6 +669,7 @@ avl_delete_worker(struct avl_tree *tree, struct avl_node *node)
return;
}
assert(node->right);
node->right->parent = parent;
if (parent->left == node)

Loading…
Cancel
Save