]> granicus.if.org Git - python/commitdiff
Issue #19437: Cleanup r_ref() of the marshal module
authorVictor Stinner <victor.stinner@gmail.com>
Thu, 31 Oct 2013 16:09:01 +0000 (17:09 +0100)
committerVictor Stinner <victor.stinner@gmail.com>
Thu, 31 Oct 2013 16:09:01 +0000 (17:09 +0100)
Python/marshal.c

index e19aff06d228ce51cecc0361d46b4188d77567ad..e211a0f01825a50aa086a1a15e66422d449da1e4 100644 (file)
@@ -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;
 }