[OpenWrt-Devel] [PATCH libubox 9/9] avl: guard against theoretical null pointer dereference

Yousong Zhou yszhou4tech at gmail.com
Wed Nov 20 07:33:06 EST 2019

On Wed, 20 Nov 2019 at 20:01, Petr Štetiar <ynezz at true.cz> wrote:
> 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.

No, theoretically it's still impossible, even if callers fiddled with
these internal members before ;)

The first check (node->left == NULL && node->right == NULL) if
matched, will return.  This commit is on 2nd check (node->left ==
NULL) which implies (node->right != NULL)


openwrt-devel mailing list
openwrt-devel at lists.openwrt.org

More information about the openwrt-devel mailing list