Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
9c187786
Commit
9c187786
authored
May 07, 2011
by
Ezio Melotti
Browse files
Options
Browse Files
Download
Plain Diff
#12017: merge with 3.2.
parents
dbf04540
06383ee0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
4 deletions
+29
-4
Lib/test/json_tests/test_recursion.py
Lib/test/json_tests/test_recursion.py
+11
-0
Misc/NEWS
Misc/NEWS
+5
-2
Modules/_json.c
Modules/_json.c
+13
-2
No files found.
Lib/test/json_tests/test_recursion.py
View file @
9c187786
...
...
@@ -65,3 +65,14 @@ 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
)
Misc/NEWS
View file @
9c187786
...
...
@@ -580,8 +580,11 @@ Tools/Demos
-
Issue
#
11179
:
Make
ccbench
work
under
Python
3.1
and
2.7
again
.
Extensions
----------
Extension
Modules
-----------------
-
Issue
#
12017
:
Fix
segfault
in
json
.
loads
()
while
decoding
highly
-
nested
objects
using
the
C
accelerations
.
-
Issue
#
1838
:
Prevent
segfault
in
ctypes
,
when
_as_parameter_
on
a
class
is
set
to
an
instance
of
the
class
.
...
...
Modules/_json.c
View file @
9c187786
...
...
@@ -943,6 +943,7 @@ scan_once_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t idx, Py_ssize_
Returns a new PyObject representation of the term.
*/
PyObject
*
res
;
Py_UNICODE
*
str
=
PyUnicode_AS_UNICODE
(
pystr
);
Py_ssize_t
length
=
PyUnicode_GET_SIZE
(
pystr
);
if
(
idx
>=
length
)
{
...
...
@@ -957,10 +958,20 @@ scan_once_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t idx, Py_ssize_
next_idx_ptr
);
case
'{'
:
/* object */
return
_parse_object_unicode
(
s
,
pystr
,
idx
+
1
,
next_idx_ptr
);
if
(
Py_EnterRecursiveCall
(
" while decoding a JSON object "
"from a unicode string"
))
return
NULL
;
res
=
_parse_object_unicode
(
s
,
pystr
,
idx
+
1
,
next_idx_ptr
);
Py_LeaveRecursiveCall
();
return
res
;
case
'['
:
/* array */
return
_parse_array_unicode
(
s
,
pystr
,
idx
+
1
,
next_idx_ptr
);
if
(
Py_EnterRecursiveCall
(
" while decoding a JSON array "
"from a unicode string"
))
return
NULL
;
res
=
_parse_array_unicode
(
s
,
pystr
,
idx
+
1
,
next_idx_ptr
);
Py_LeaveRecursiveCall
();
return
res
;
case
'n'
:
/* null */
if
((
idx
+
3
<
length
)
&&
str
[
idx
+
1
]
==
'u'
&&
str
[
idx
+
2
]
==
'l'
&&
str
[
idx
+
3
]
==
'l'
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment