Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
9f69e79c
Kaydet (Commit)
9f69e79c
authored
Kas 01, 2012
tarafından
Antoine Pitrou
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #16228: Fix a crash in the json module where a list changes size while it is being encoded.
Patch by Serhiy Storchaka.
üst
42d5c415
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
7 deletions
+14
-7
test_dump.py
Lib/test/json_tests/test_dump.py
+8
-0
NEWS
Misc/NEWS
+3
-0
_json.c
Modules/_json.c
+3
-7
No files found.
Lib/test/json_tests/test_dump.py
Dosyayı görüntüle @
9f69e79c
...
@@ -19,6 +19,14 @@ class TestDump:
...
@@ -19,6 +19,14 @@ class TestDump:
{
2
:
3.0
,
4.0
:
5
,
False
:
1
,
6
:
True
},
sort_keys
=
True
),
{
2
:
3.0
,
4.0
:
5
,
False
:
1
,
6
:
True
},
sort_keys
=
True
),
'{"false": 1, "2": 3.0, "4.0": 5, "6": true}'
)
'{"false": 1, "2": 3.0, "4.0": 5, "6": true}'
)
# Issue 16228: Crash on encoding resized list
def
test_encode_mutated
(
self
):
a
=
[
object
()]
*
10
def
crasher
(
obj
):
del
a
[
-
1
]
self
.
assertEqual
(
self
.
dumps
(
a
,
default
=
crasher
),
'[null, null, null, null, null]'
)
class
TestPyDump
(
TestDump
,
PyTest
):
pass
class
TestPyDump
(
TestDump
,
PyTest
):
pass
class
TestCDump
(
TestDump
,
CTest
):
pass
class
TestCDump
(
TestDump
,
CTest
):
pass
Misc/NEWS
Dosyayı görüntüle @
9f69e79c
...
@@ -143,6 +143,9 @@ Core and Builtins
...
@@ -143,6 +143,9 @@ Core and Builtins
Library
Library
-------
-------
- Issue #16228: Fix a crash in the json module where a list changes size
while it is being encoded. Patch by Serhiy Storchaka.
- Issue #14897: Enhance error messages of struct.pack and
- Issue #14897: Enhance error messages of struct.pack and
struct.pack_into. Patch by Matti Mäki.
struct.pack_into. Patch by Matti Mäki.
...
...
Modules/_json.c
Dosyayı görüntüle @
9f69e79c
...
@@ -1585,8 +1585,6 @@ encoder_listencode_list(PyEncoderObject *s, PyObject *rval, PyObject *seq, Py_ss
...
@@ -1585,8 +1585,6 @@ encoder_listencode_list(PyEncoderObject *s, PyObject *rval, PyObject *seq, Py_ss
static
PyObject
*
empty_array
=
NULL
;
static
PyObject
*
empty_array
=
NULL
;
PyObject
*
ident
=
NULL
;
PyObject
*
ident
=
NULL
;
PyObject
*
s_fast
=
NULL
;
PyObject
*
s_fast
=
NULL
;
Py_ssize_t
num_items
;
PyObject
**
seq_items
;
Py_ssize_t
i
;
Py_ssize_t
i
;
if
(
open_array
==
NULL
||
close_array
==
NULL
||
empty_array
==
NULL
)
{
if
(
open_array
==
NULL
||
close_array
==
NULL
||
empty_array
==
NULL
)
{
...
@@ -1600,8 +1598,7 @@ encoder_listencode_list(PyEncoderObject *s, PyObject *rval, PyObject *seq, Py_ss
...
@@ -1600,8 +1598,7 @@ encoder_listencode_list(PyEncoderObject *s, PyObject *rval, PyObject *seq, Py_ss
s_fast
=
PySequence_Fast
(
seq
,
"_iterencode_list needs a sequence"
);
s_fast
=
PySequence_Fast
(
seq
,
"_iterencode_list needs a sequence"
);
if
(
s_fast
==
NULL
)
if
(
s_fast
==
NULL
)
return
-
1
;
return
-
1
;
num_items
=
PySequence_Fast_GET_SIZE
(
s_fast
);
if
(
PySequence_Fast_GET_SIZE
(
s_fast
)
==
0
)
{
if
(
num_items
==
0
)
{
Py_DECREF
(
s_fast
);
Py_DECREF
(
s_fast
);
return
PyList_Append
(
rval
,
empty_array
);
return
PyList_Append
(
rval
,
empty_array
);
}
}
...
@@ -1622,7 +1619,6 @@ encoder_listencode_list(PyEncoderObject *s, PyObject *rval, PyObject *seq, Py_ss
...
@@ -1622,7 +1619,6 @@ encoder_listencode_list(PyEncoderObject *s, PyObject *rval, PyObject *seq, Py_ss
}
}
}
}
seq_items
=
PySequence_Fast_ITEMS
(
s_fast
);
if
(
PyList_Append
(
rval
,
open_array
))
if
(
PyList_Append
(
rval
,
open_array
))
goto
bail
;
goto
bail
;
if
(
s
->
indent
!=
Py_None
)
{
if
(
s
->
indent
!=
Py_None
)
{
...
@@ -1634,8 +1630,8 @@ encoder_listencode_list(PyEncoderObject *s, PyObject *rval, PyObject *seq, Py_ss
...
@@ -1634,8 +1630,8 @@ encoder_listencode_list(PyEncoderObject *s, PyObject *rval, PyObject *seq, Py_ss
buf += newline_indent
buf += newline_indent
*/
*/
}
}
for
(
i
=
0
;
i
<
num_items
;
i
++
)
{
for
(
i
=
0
;
i
<
PySequence_Fast_GET_SIZE
(
s_fast
)
;
i
++
)
{
PyObject
*
obj
=
seq_items
[
i
]
;
PyObject
*
obj
=
PySequence_Fast_GET_ITEM
(
s_fast
,
i
)
;
if
(
i
)
{
if
(
i
)
{
if
(
PyList_Append
(
rval
,
s
->
item_separator
))
if
(
PyList_Append
(
rval
,
s
->
item_separator
))
goto
bail
;
goto
bail
;
...
...
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