Skip to content

Flush Python stream item markers before unchecked writes#290

Open
KairosOps wants to merge 1 commit into
microsoft:mainfrom
KairosOps:fix/python-stream-marker-flush
Open

Flush Python stream item markers before unchecked writes#290
KairosOps wants to merge 1 commit into
microsoft:mainfrom
KairosOps:fix/python-stream-marker-flush

Conversation

@KairosOps

Copy link
Copy Markdown

Fixes #289.

The per-item streaming path in the Python binary runtime writes the stream item marker with write_byte_no_check(1). When an element lands exactly at the end of the output buffer, the next marker writes past the bytearray before any element serializer gets a chance to flush.

This gives the marker the same one-byte capacity guarantee used by the nearby tag writers. I added a small regression test that uses a 2-byte buffer and optional values so the boundary is hit deterministically.

Checked locally:

  • python -m pytest python\tests\test_binary_stream_writer.py -q
  • python -m py_compile tooling\internal\python\static_files\_binary.py python\tests\test_binary_stream_writer.py
  • git diff --cached --check

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.

Python binary stream writer buffer overflow

1 participant