gsequence: Squash a static analysis false positive

scan-build thinks there can be a `NULL` pointer dereference in `while
((i = N_NODES (node->left)) != pos)`, if `node` is `NULL`.

`node` cannot be `NULL`, though, assuming the `n_nodes` member of each
node in the tree is an accurate count of the number of nodes beneath
that point. It controls the tree descent and avoids trying to descend
beneath a leaf.

A static analyser can’t know this though, so let’s add an assertion to
help.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>

Helps: #1767
This commit is contained in:
Philip Withnall 2024-04-09 16:21:02 +01:00
parent ff4c17bc30
commit c4affcb4f0
No known key found for this signature in database
GPG Key ID: DCDF5885B1F3ED73

View File

@ -1732,6 +1732,7 @@ node_get_by_pos (GSequenceNode *node,
{
node = node->left;
}
g_assert (node != NULL);
}
return node;