Skip to content

A14-08: expected_mi() reads ni[1] out of bounds with no length check (unlike the sibling mi_key) #104

Description

@ms609

src/expected_mi.cpp:56-60 — no length check on ni, unlike mi_key at :115 which validates ni.size()==2. Exported and documented with a worked example.

Reproduced by the haiku verifier: expected_mi(3L, c(2L,5L)) returns 0.0004173666 with an Rcpp bounds warning in a debug build; a release/NDEBUG build would read freed/adjacent memory silently instead of warning.

Fix: validate ni.size() == 2 (or whatever the correct expected length is) at function entry, matching mi_key's existing guard.

Filed by /red-team area 14 (opus finder, 2026-08-05), confirmed by haiku verifier with live repro.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:14Red-team focus area 14in-progressBeing fixed; claiming comment names the branchred-teamFiled by the /red-team rotationsev:lowP3: robustness / polish

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions