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 <[email protected]>
---
 avl.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/avl.c b/avl.c
index 8d0bf65aaa5b..e5584051ab94 100644
--- a/avl.c
+++ b/avl.c
@@ -668,7 +668,8 @@ avl_delete_worker(struct avl_tree *tree, struct avl_node 
*node)
       return;
     }
 
-    node->right->parent = parent;
+    if (node->right)
+      node->right->parent = parent;
 
     if (parent->left == node)
       parent->left = node->right;

_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to