summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-10-31 16:14:52 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-10-31 16:14:52 (GMT)
commitd5cae6f143fbb24fde667f28bf42e8e4fb0ea1dc (patch)
tree1f6db14b6f9e29908e2b4bafc3a0d2011fe7b225 /Python
parentb1b7b1834b5b5dd989b0295a3be3401569714ccc (diff)
downloadcpython-d5cae6f143fbb24fde667f28bf42e8e4fb0ea1dc.zip
cpython-d5cae6f143fbb24fde667f28bf42e8e4fb0ea1dc.tar.gz
cpython-d5cae6f143fbb24fde667f28bf42e8e4fb0ea1dc.tar.bz2
Issue #19437: Fix r_object() of marshal module, handle PyDict_SetItem() failure
for TYPE_DICT and stop immedialty on first r_object() failure
Diffstat (limited to 'Python')
-rw-r--r--Python/marshal.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/Python/marshal.c b/Python/marshal.c
index 598269f..e19aff0 100644
--- a/Python/marshal.c
+++ b/Python/marshal.c
@@ -1117,6 +1117,7 @@ r_object(RFILE *p)
R_REF(v);
if (v == NULL)
break;
+
for (i = 0; i < n; i++) {
v2 = r_object(p);
if ( v2 == NULL ) {
@@ -1170,10 +1171,17 @@ r_object(RFILE *p)
if (key == NULL)
break;
val = r_object(p);
- if (val != NULL)
- PyDict_SetItem(v, key, val);
+ if (val == NULL) {
+ Py_DECREF(key);
+ break;
+ }
+ if (PyDict_SetItem(v, key, val) < 0) {
+ Py_DECREF(key);
+ Py_DECREF(val);
+ break;
+ }
Py_DECREF(key);
- Py_XDECREF(val);
+ Py_DECREF(val);
}
if (PyErr_Occurred()) {
Py_DECREF(v);
@@ -1204,6 +1212,7 @@ r_object(RFILE *p)
}
if (v == NULL)
break;
+
for (i = 0; i < n; i++) {
v2 = r_object(p);
if ( v2 == NULL ) {