diff options
author | Ezio Melotti <ezio.melotti@gmail.com> | 2011-05-07 14:58:09 (GMT) |
---|---|---|
committer | Ezio Melotti <ezio.melotti@gmail.com> | 2011-05-07 14:58:09 (GMT) |
commit | 362b95102f76d042e7f3865c1ebec5d36c79959a (patch) | |
tree | a9c0400d35a1806e92ee78378e4aae30f9492791 /Lib/json | |
parent | 7420b70240586b700f5cadfa0bbdffbbe6cb8e5a (diff) | |
download | cpython-362b95102f76d042e7f3865c1ebec5d36c79959a.zip cpython-362b95102f76d042e7f3865c1ebec5d36c79959a.tar.gz cpython-362b95102f76d042e7f3865c1ebec5d36c79959a.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 | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/json/tests/test_recursion.py b/Lib/json/tests/test_recursion.py index 1e9b8ab..6d5db50 100644 --- a/Lib/json/tests/test_recursion.py +++ b/Lib/json/tests/test_recursion.py @@ -65,3 +65,15 @@ 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 + 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) + |