Skip to content

Respect logical bounds in deque and vector reads - #255

Closed
Aschenbath wants to merge 1 commit into
Yomguithereal:masterfrom
Aschenbath:fix/logical-get-bounds-254
Closed

Aschenbath wants to merge 1 commit into
Yomguithereal:masterfrom
Aschenbath:fix/logical-get-bounds-254

Conversation

@Aschenbath

Copy link
Copy Markdown

After removing elements, FixedDeque#get, CircularBuffer#get and Vector#get could return a removed value from the backing array. Reads from unused typed-array capacity could also return zero. Check the current size or length so an index at or beyond the end returns undefined.

Adds 18 regression cases across Array, Uint8Array and Float64Array, covering unused capacity, pop, shift, wraparound, clear/refill and vector shrink/grow operations. All 18 fail before the fix.

Fixes #254.

Validation on Windows:

  • Node 18.20.8 and 24.22.0: full suite passes with 580 passing and 1 existing pending test on each.
  • npm run lint and npm run test:exports pass. The export checks use TypeScript 5.3.3, Git's mv on the process PATH and npm_config_install_links=true.
  • Installed-package checks pass 810 assertions on each runtime across CommonJS, ESM and subpath imports.
  • Independent review passes 72,000 random operations and 1,284,404 indexed-read assertions, including all 10 vector subclasses.

Prepared and tested with OpenAI Codex assistance; no human review is claimed.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

get(index) past the end returns removed items in FixedDeque, CircularBuffer, and Vector

2 participants