]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib/util: clang: Fix dereference of a null pointer warning
authorNoel Power <noel.power@suse.com>
Fri, 24 May 2019 14:08:58 +0000 (14:08 +0000)
committerNoel Power <npower@samba.org>
Tue, 11 Jun 2019 12:10:17 +0000 (12:10 +0000)
Fixes:

lib/util/rbtree.c:170:8: warning: Access to field 'rb_parent_color' results in a dereference of a null pointer (loaded from variable 'other') <--[clang]

We could avoid accessing the NULL pointer but previously the code would
have crashed here. Given this is a rbtree probably better to preserve the
fatal nature of encountering a NULL pointer here while satisfying the static
checker.

Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Gary Lockyer gary@catalyst.net.nz
lib/util/rbtree.c

index b7add66234fefaa656b5399517c1bb1b2c2be406..aa663f49f028faa0ff5e63c0cb549aa628b96098 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "replace.h"
 #include "rbtree.h"
+#include "fault.h"
 
 #define        RB_RED          0
 #define        RB_BLACK        1
@@ -167,6 +168,12 @@ static void __rb_erase_color(struct rb_node *node, struct rb_node *parent,
                if (parent->rb_left == node)
                {
                        other = parent->rb_right;
+                       if (other == NULL) {
+                               /* we should never get here */
+                               smb_panic("corrupted rb tree");
+                               /* satisfy static checkers */
+                               return;
+                       }
                        if (rb_is_red(other))
                        {
                                rb_set_black(other);