uid-range: add assert to prevent underflow in coalesce loop

Coverity flags range->n_entries - j as a potential underflow
in the memmove size calculation. Add assert(range->n_entries > 0)
before decrementing n_entries, which holds since the loop condition
guarantees j < n_entries.

CID#1548015

Follow-up for 8dcc66cefc
This commit is contained in:
Luca Boccassi
2026-04-12 13:24:50 +01:00
parent 04e05ab724
commit ff102359b7
+2
View File
@@ -75,6 +75,8 @@ static void uid_range_coalesce(UIDRange *range) {
if (range->n_entries > j + 1)
memmove(y, y + 1, sizeof(UIDRangeEntry) * (range->n_entries - j - 1));
/* Silence static analyzers, n_entries > 0 since j < n_entries holds in the loop condition */
assert(range->n_entries > 0);
range->n_entries--;
/* Silence static analyzers, j cannot be 0 here since it starts at i + 1, i.e. >= 1 */