Skip to content

pass_similarity calls qsort with a null base for an empty fingerprint set #1367

Description

@WarGloom

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions