Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
the C Packer only checks for exported buffers when pack() starts, but default (and the iteration in pack_map_pairs) runs arbitrary python while packing. if that code calls memoryview(packer), the outer pack keeps writing and msgpack_pack_write reallocs pk.buf, so the view is left pointing at freed memory. with PYTHONMALLOC=debug, a default that grabs the view and returns b"x" * (1 << 20) on Packer(default=default, buf_size=1024) gives a view that reads back 0xdd bytes. calling packer.pack() from default has a related problem: autoreset zeroes pk.length under the outer call and its output is silently corrupted. this adds a _packing flag set by pack() and pack_map_pairs(), the same way #704 guarded Unpacker. getbuffer raises BufferError and re-entry raises RuntimeError while the flag is set. pack_ext_type is left alone because #765 already removes the len() call, which was the only python it ran. the fallback writes through BytesIO, which already refuses resizing while exported, so the new test is C-only. the test fails on main and passes with the change; pytest passes for both the C and pure-python builds.