What happens
collect_fp_entries() starts with entries == NULL and calls
qsort(entries, count, ...) unconditionally. When a graph buffer has no
Function/Method nodes with fingerprints, count == 0, so the call is
qsort(NULL, 0, ...).
The project targets C standards where the sorting API is specified in terms of
base pointing at an array. Zero elements suppress comparator calls, but do not
make a null base a portable array pointer. Sorting is also unnecessary for the
one-entry case.
Proposed fix
Call qsort only when count > 1. This preserves deterministic ordering for
the only case that needs sorting and avoids passing an empty null buffer into
the C library.
Scope
src/pipeline/pass_similarity.c
- no behavior change for two or more entries
- no new dependency or API change
Validation
The focused sanitizer-backed simhash suite passes: 24 tests.
What happens
collect_fp_entries()starts withentries == NULLand callsqsort(entries, count, ...)unconditionally. When a graph buffer has noFunction/Method nodes with fingerprints,
count == 0, so the call isqsort(NULL, 0, ...).The project targets C standards where the sorting API is specified in terms of
basepointing at an array. Zero elements suppress comparator calls, but do notmake a null base a portable array pointer. Sorting is also unnecessary for the
one-entry case.
Proposed fix
Call
qsortonly whencount > 1. This preserves deterministic ordering forthe only case that needs sorting and avoids passing an empty null buffer into
the C library.
Scope
src/pipeline/pass_similarity.cValidation
The focused sanitizer-backed
simhashsuite passes: 24 tests.