Skip to content

Fix FlexBuffers ArrayBufferView serialization bounds handling#9095

Open
kmackinley wants to merge 1 commit into
google:masterfrom
kmackinley:flexbuffers-arraybufferview-bounds
Open

Fix FlexBuffers ArrayBufferView serialization bounds handling#9095
kmackinley wants to merge 1 commit into
google:masterfrom
kmackinley:flexbuffers-arraybufferview-bounds

Conversation

@kmackinley
Copy link
Copy Markdown

Summary

Preserve byteOffset and byteLength when serializing ArrayBufferView inputs in the TypeScript FlexBuffers builder.

Previously, ArrayBuffer.isView(value) passed value.buffer directly to writeBlob(), which serialized the entire backing ArrayBuffer instead of the visible view range. That could cause Uint8Array.subarray(), DataView, and Node.js Buffer views to serialize adjacent bytes outside the caller-selected bounds.

Fix

  • Add writeBlobView() for ArrayBufferView inputs.
  • Preserve byteOffset and byteLength when copying blob bytes.
  • Keep raw ArrayBuffer blob behavior unchanged.
  • Add regression coverage for Uint8Array.subarray() and DataView inputs.

Tests

  • npm run compile
  • npm run lint
  • node JavaScriptFlexBuffersTest.js from tests/ts with a temporary local workspace package link
  • Targeted Node repro for Uint8Array.subarray() and DataView view bounds

@kmackinley kmackinley marked this pull request as ready for review May 16, 2026 04:52
@kmackinley kmackinley requested a review from dbaileychess as a code owner May 16, 2026 04:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant