Covscan complained about potential deref of NULL 'lei' pointer, Interestingly this can't happen as the relevant goto leading to that (in line 260) sits in code checking conflicts between new intervals and since those are sorted upon insertion, only the lower boundary may conflict (or both, but that's covered before). Given the needed investigation to proof covscan wrong and the actually wrong (but impossible) code, better fix this as if element ordering was arbitrary to avoid surprises if at some point it really becomes that. Fixes: 4d6ad0f310d6c ("segtree: check for overlapping elements at insertion") Signed-off-by: Phil Sutter <phil@xxxxxx> --- src/segtree.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/segtree.c b/src/segtree.c index e8e32412f3a41..04c0e915263b9 100644 --- a/src/segtree.c +++ b/src/segtree.c @@ -205,8 +205,11 @@ static int ei_insert(struct list_head *msgs, struct seg_tree *tree, pr_gmp_debug("insert: [%Zx %Zx]\n", new->left, new->right); if (lei != NULL && rei != NULL && lei == rei) { - if (!merge) + if (!merge) { + expr_binary_error(msgs, lei->expr, new->expr, + "conflicting intervals specified"); goto err; + } /* * The new interval is entirely contained in the same interval, * split it into two parts: @@ -228,8 +231,11 @@ static int ei_insert(struct list_head *msgs, struct seg_tree *tree, ei_destroy(lei); } else { if (lei != NULL) { - if (!merge) + if (!merge) { + expr_binary_error(msgs, lei->expr, new->expr, + "conflicting intervals specified"); goto err; + } /* * Left endpoint is within lei, adjust it so we have: * @@ -248,8 +254,11 @@ static int ei_insert(struct list_head *msgs, struct seg_tree *tree, } } if (rei != NULL) { - if (!merge) + if (!merge) { + expr_binary_error(msgs, rei->expr, new->expr, + "conflicting intervals specified"); goto err; + } /* * Right endpoint is within rei, adjust it so we have: * @@ -276,8 +285,7 @@ static int ei_insert(struct list_head *msgs, struct seg_tree *tree, return 0; err: errno = EEXIST; - return expr_binary_error(msgs, lei->expr, new->expr, - "conflicting intervals specified"); + return -1; } /* -- 2.24.1