mirror of
https://github.com/python/cpython.git
synced 2025-08-18 07:41:05 +00:00
#12017: Fix segfault in json.loads() while decoding highly-nested objects using the C accelerations.
This commit is contained in:
parent
5ae6c42f52
commit
cec464951e
3 changed files with 48 additions and 4 deletions
|
@ -65,3 +65,22 @@ class TestRecursion(TestCase):
|
|||
pass
|
||||
else:
|
||||
self.fail("didn't raise ValueError on default recursion")
|
||||
|
||||
|
||||
def test_highly_nested_objects(self):
|
||||
# test that loading highly-nested objects doesn't segfault when C
|
||||
# accelerations are used. See #12017
|
||||
# str
|
||||
with self.assertRaises(RuntimeError):
|
||||
json.loads('{"a":' * 100000 + '1' + '}' * 100000)
|
||||
with self.assertRaises(RuntimeError):
|
||||
json.loads('{"a":' * 100000 + '[1]' + '}' * 100000)
|
||||
with self.assertRaises(RuntimeError):
|
||||
json.loads('[' * 100000 + '1' + ']' * 100000)
|
||||
# unicode
|
||||
with self.assertRaises(RuntimeError):
|
||||
json.loads(u'{"a":' * 100000 + u'1' + u'}' * 100000)
|
||||
with self.assertRaises(RuntimeError):
|
||||
json.loads(u'{"a":' * 100000 + u'[1]' + u'}' * 100000)
|
||||
with self.assertRaises(RuntimeError):
|
||||
json.loads(u'[' * 100000 + u'1' + u']' * 100000)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue