If the default callback obtains a memoryview through getbuffer() and then returns a sufficiently large value, Packer.pack() reallocates its internal buffer while the memoryview still references the old storage.
Accessing the memoryview afterward causes a segmentation fault, and an ASan build reports a heap-use-after-free.
An ASan build reports a heap-use-after-free in unpack_execute.
The allocation was freed by msgpack_pack_write after the callback exported a memoryview of the buffer.
I found this while fuzzing Python C extension modules.
It looks like a bug to me, but I may be missing an intended constraint, so I would appreciate confirmation.
Activity