Issue #19437: Fix r_object() of marshal module, handle PyDict_SetItem() failure

for TYPE_DICT and stop immedialty on first r_object() failure
This commit is contained in:
Victor Stinner 2013-10-31 17:14:52 +01:00
parent b1b7b1834b
commit d5cae6f143
1 changed files with 12 additions and 3 deletions

View File

@ -1117,6 +1117,7 @@ r_object(RFILE *p)
R_REF(v); R_REF(v);
if (v == NULL) if (v == NULL)
break; break;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
v2 = r_object(p); v2 = r_object(p);
if ( v2 == NULL ) { if ( v2 == NULL ) {
@ -1170,10 +1171,17 @@ r_object(RFILE *p)
if (key == NULL) if (key == NULL)
break; break;
val = r_object(p); val = r_object(p);
if (val != NULL) if (val == NULL) {
PyDict_SetItem(v, key, val); Py_DECREF(key);
break;
}
if (PyDict_SetItem(v, key, val) < 0) {
Py_DECREF(key);
Py_DECREF(val);
break;
}
Py_DECREF(key); Py_DECREF(key);
Py_XDECREF(val); Py_DECREF(val);
} }
if (PyErr_Occurred()) { if (PyErr_Occurred()) {
Py_DECREF(v); Py_DECREF(v);
@ -1204,6 +1212,7 @@ r_object(RFILE *p)
} }
if (v == NULL) if (v == NULL)
break; break;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
v2 = r_object(p); v2 = r_object(p);
if ( v2 == NULL ) { if ( v2 == NULL ) {