#12017: Fix segfault in json.loads() while decoding highly-nested objects using the C accelerations.

This commit is contained in:
Ezio Melotti 2011-05-07 17:40:23 +03:00
parent 5ae6c42f52
commit cec464951e
3 changed files with 48 additions and 4 deletions

View file

@ -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)