1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-08 21:18:16 +03:00

lib/util: clang: Fix dereference of a null pointer warning

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
This commit is contained in:
Noel Power 2019-05-24 14:08:58 +00:00 committed by Noel Power
parent acd6554206
commit e104c01846

View 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);