]> granicus.if.org Git - python/commitdiff
Fix leak of NotImplemented in previous checkin to PyNumber_Add().
authorJeremy Hylton <jeremy@alum.mit.edu>
Fri, 8 Mar 2002 21:28:54 +0000 (21:28 +0000)
committerJeremy Hylton <jeremy@alum.mit.edu>
Fri, 8 Mar 2002 21:28:54 +0000 (21:28 +0000)
If result == Py_NotImplemented, always DECREF it before assigning a
new value to result.

Objects/abstract.c

index 2207602550ce98f6ea3f8b04ce2cc166940bd157..162c53c9b3671d74be6f2b7d4e2f416ffbe88e9f 100644 (file)
@@ -605,16 +605,18 @@ PyNumber_Add(PyObject *v, PyObject *w)
        PyObject *result = binary_op1(v, w, NB_SLOT(nb_add));
        if (result == Py_NotImplemented) {
                PySequenceMethods *m = v->ob_type->tp_as_sequence;
-               Py_DECREF(result);
-               if (m && m->sq_concat)
+               if (m && m->sq_concat) {
+                       Py_DECREF(result);
                        result = (*m->sq_concat)(v, w);
+               }
                if (result == Py_NotImplemented) {
-                    PyErr_Format(
+                       Py_DECREF(result);
+                       PyErr_Format(
                            PyExc_TypeError,
                            "unsupported operand types for +: '%s' and '%s'",
                            v->ob_type->tp_name,
                            w->ob_type->tp_name);
-                    result = NULL;
+                       result = NULL;
                 }
        }
        return result;