diff options
author | Thomas Haller <thaller@redhat.com> | 2023-03-10 15:13:18 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2023-03-21 15:58:39 +0100 |
commit | d840ddd95959d8a6f4d7e9b1d7065d38bdbfed29 (patch) | |
tree | b585b7c57638ca25b151585a7288155ef0018c55 /src/libnm-lldp | |
parent | 78489e7cbb1edfc15f60faa15c7488fe40031c5c (diff) | |
download | NetworkManager-d840ddd95959d8a6f4d7e9b1d7065d38bdbfed29.tar.gz |
glib-aux/prioq: assert for valid index in find_item() of NMPrioq
NMPrioq is taken from systemd's "prioq.c". It is a nice data structure,
that accepts and an index pointer, to directly access elements inside
the heap.
Previously, the API didn't require a consistent index, while the data is
not inside the heap. nm_prioq_{update,shuffle,remove}()) call find_item(),
which silently accepts wrong indexes and assumes the element is not in
the heap.
Keeping the index in sync with the data seems error prone. Accepting any
index without asserting may be convenient for the user (as the user is
not required to pre-initialize the index with NM_PRIOQ_IDX_NULL).
However, it also misses to catch potential bugs.
Now the index must be kept consistent, in particular also if the element
is not enqueued. This means, you must initialize them with
NM_PRIOQ_IDX_NULL.
Diffstat (limited to 'src/libnm-lldp')
-rw-r--r-- | src/libnm-lldp/nm-lldp-neighbor.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/src/libnm-lldp/nm-lldp-neighbor.c b/src/libnm-lldp/nm-lldp-neighbor.c index f1e2d42eb0..a2a9695e85 100644 --- a/src/libnm-lldp/nm-lldp-neighbor.c +++ b/src/libnm-lldp/nm-lldp-neighbor.c @@ -735,6 +735,7 @@ nm_lldp_neighbor_new(size_t raw_size) n->raw_size = raw_size; n->ref_count = 1; + n->prioq_idx = NM_PRIOQ_IDX_NULL; return n; } |