diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2011-05-07 14:40:23 (GMT) |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2011-05-07 14:40:23 (GMT) |
commit | cec464951e06dd9388352590eb1f17b9aa3d68a5 (patch) | |
tree | e9f8449b949cab39476f57c9b68670b5b2578940 /Lib/json | |
parent | 5ae6c42f52c650dc317dd5f0ecab8d5087c44872 (diff) | |
download | cpython-cec464951e06dd9388352590eb1f17b9aa3d68a5.zip cpython-cec464951e06dd9388352590eb1f17b9aa3d68a5.tar.gz cpython-cec464951e06dd9388352590eb1f17b9aa3d68a5.tar.bz2 |
#12017: Fix segfault in json.loads() while decoding highly-nested objects using the C accelerations.
Diffstat (limited to 'Lib/json')
-rw-r--r-- | Lib/json/tests/test_recursion.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/json/tests/test_recursion.py b/Lib/json/tests/test_recursion.py index 1e9b8ab..548bb89 100644 --- a/Lib/json/tests/test_recursion.py +++ b/Lib/json/tests/test_recursion.py @@ -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) |