8000 Fix Unpacker.feed() drops unused data in buffer. (#289) · devendor/msgpack-python@f38c1a3 · GitHub
[go: up one dir, main page]

Skip to content

Commit f38c1a3

Browse files
authored
Fix Unpacker.feed() drops unused data in buffer. (msgpack#289)
Fixes msgpack#287
1 parent fbaa136 commit f38c1a3
8000

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

msgpack/fallback.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,8 +289,13 @@ def feed(self, next_bytes):
289289
view = _get_data_from_buffer(next_bytes)
290290
if (len(self._buffer) - self._buff_i + len(view) > self._max_buffer_size):
291291
raise BufferFull
292-
del self._buffer[:self._buff_i]
293-
self._buff_i = 0
292+
293+
# Strip buffer before checkpoint before reading file.
294+
if self._buf_checkpoint > 0:
295+
del self._buffer[:self._buf_checkpoint]
296+
self._buff_i -= self._buf_checkpoint
297+
self._buf_checkpoint = 0
298+
294299
self._buffer += view
295300

296301
def _consume(self):

0 commit comments

Comments
 (0)
0