Skip to content

Commit b691a8e

Browse files
committed
Add missing autoreset in Packer.pack_ext_type
pack_ext_type writes to the internal buffer but never checks self._autoreset, unlike every other public pack method. This means it always returns None and the packed data leaks into the output of the next pack() call, corrupting the serialized stream. Add the same autoreset pattern used by pack(), pack_map_pairs(), pack_array_header(), and pack_map_header().
1 parent f980636 commit b691a8e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

msgpack/fallback.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,10 @@ def pack_ext_type(self, typecode, data):
861861
self._buffer.write(b"\xc9" + struct.pack(">I", L))
862862
self._buffer.write(struct.pack("B", typecode))
863863
self._buffer.write(data)
864+
if self._autoreset:
865+
ret = self._buffer.getvalue()
866+
self._buffer = BytesIO()
867+
return ret
864868

865869
def _pack_array_header(self, n):
866870
if n <= 0x0F:

0 commit comments

Comments
 (0)