Skip to content

unbounded-vec-growth's length-check detection is satisfied by any .len() call anywhere in the function #365

Description

@unrealtim-tech

Labels: bug, checks-crate
Crate: checks

Description
crates/checks/src/vec_growth.rs (lines ~69-89) sets has_len_check = true on any .len() method call found anywhere in the method body, with no correlation to the receiver or to whether it actually gates the push/push_back call:

if method == "len" {
    self.has_len_check = true;
}

A .len() call on an unrelated collection (e.g. logging other_vec.len()) suppresses the finding even when the actual storage-backed Vec being grown has no cap at all. This is the same "presence, not gating condition" defect class already tracked for unchecked-arithmetic (issue #278), recurring independently in this check.

Acceptance Criteria

  • Require the .len() call to be on the same receiver/variable as the vector being pushed to (or otherwise demonstrably gate the push), not just present anywhere in the function.
  • Add a test with an unrelated .len() call plus a genuinely unbounded push, asserting a finding is still produced.

Difficulty: intermediate

Metadata

Metadata

Assignees

No one assigned

    Labels

    Stellar WaveIssues in the Stellar wave programbugSomething isn't workingchecks-crate

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions