FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: translate RecursionError to StackError in fallback Unpacker.skip() by hdimer · Pull Request #727 · msgpack/msgpack-python · GitHub

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
5 changes: 4 additions & 1 deletion msgpack/fallback.py
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
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,10 @@ def __next__(self):
next = __next__

def skip(self):
self._unpack(EX_SKIP)
try:
self._unpack(EX_SKIP)
except RecursionError:
raise StackError
self._consume()

def unpack(self):
Expand Down
5 changes: 5 additions & 0 deletions test/test_except.py
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
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ def test_invalidvalue():
with raises(StackError):
unpackb(b"\x91" * 3000) # nested fixarray(len=1)

with raises(StackError):
unpacker = Unpacker()
unpacker.feed(b"\x91" * 3000)
unpacker.skip()


def test_no_memory_leak_on_nested_invalid_tag() -> None:
"""Regression test: unpacking nested arrays containing an invalid tag must not leak objects."""
Expand Down

Back | FazBrowse Home | New Git URL