summaryrefslogtreecommitdiff
path: root/Lib
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2011-05-07 17:40:23 +0300
committerEzio Melotti <ezio.melotti@gmail.com>2011-05-07 17:40:23 +0300
commit9e00938f25f80bbff05c6946062a767f11123848 (patch)
tree760c47a46ea2842428285e1b7939b1f9e9a8d4d7 /Lib
parent6a9182d09877ea797ab029f1c28ca9983921666f (diff)
downloadcpython-9e00938f25f80bbff05c6946062a767f11123848.tar.gz
#12017: Fix segfault in json.loads() while decoding highly-nested objects using the C accelerations.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/json/tests/test_recursion.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/json/tests/test_recursion.py b/Lib/json/tests/test_recursion.py
index 1e9b8ab757..548bb89ed5 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)