From d5cae6f143fbb24fde667f28bf42e8e4fb0ea1dc Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 31 Oct 2013 17:14:52 +0100 Subject: Issue #19437: Fix r_object() of marshal module, handle PyDict_SetItem() failure for TYPE_DICT and stop immedialty on first r_object() failure --- Python/marshal.c | 15 ++++++++++++--- 1 file 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 ) { -- cgit v0.12