From: Victor Stinner Date: Thu, 31 Oct 2013 16:09:01 +0000 (+0100) Subject: Issue #19437: Cleanup r_ref() of the marshal module X-Git-Tag: v3.4.0b1~445 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=359fabc19f28187305c9212796f390b5b4d8d64a;p=python Issue #19437: Cleanup r_ref() of the marshal module --- diff --git a/Python/marshal.c b/Python/marshal.c index e19aff06d2..e211a0f018 100644 --- a/Python/marshal.c +++ b/Python/marshal.c @@ -827,11 +827,12 @@ r_ref_insert(PyObject *o, Py_ssize_t idx, int flag, RFILE *p) static PyObject * r_ref(PyObject *o, int flag, RFILE *p) { - if (o != NULL && flag) { /* currently only FLAG_REF is defined */ - if (PyList_Append(p->refs, o) < 0) { - Py_DECREF(o); /* release the new object */ - return NULL; - } + assert(flag & FLAG_REF); + if (o == NULL) + return NULL; + if (PyList_Append(p->refs, o) < 0) { + Py_DECREF(o); /* release the new object */ + return NULL; } return o; }