From 9b6ede0e5312071400e6b009c6b92413061bbfaa Mon Sep 17 00:00:00 2001 From: =?utf8?q?Petr=20=C5=A0tetiar?= Date: Wed, 20 Nov 2019 09:31:08 +0100 Subject: [PATCH] avl: guard against theoretical null pointer dereference MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- avl.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/avl.c b/avl.c index 8d0bf65..79ea5c7 100644 --- a/avl.c +++ b/avl.c @@ -45,6 +45,7 @@ #include #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) -- 2.30.2