diff --git a/Misc/NEWS.d/next/Core and Builtins/2018-05-02-08-36-03.bpo-33391.z4a7rb.rst b/Misc/NEWS.d/next/Core and Builtins/2018-05-02-08-36-03.bpo-33391.z4a7rb.rst new file mode 100644 index 00000000000..ab17aa408c0 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2018-05-02-08-36-03.bpo-33391.z4a7rb.rst @@ -0,0 +1 @@ +Fix a leak in set_symmetric_difference(). diff --git a/Objects/setobject.c b/Objects/setobject.c index 154be43564d..31da3dbfecb 100644 --- a/Objects/setobject.c +++ b/Objects/setobject.c @@ -1710,8 +1710,10 @@ set_symmetric_difference(PySetObject *so, PyObject *other) if (otherset == NULL) return NULL; rv = set_symmetric_difference_update(otherset, (PyObject *)so); - if (rv == NULL) + if (rv == NULL) { + Py_DECREF(otherset); return NULL; + } Py_DECREF(rv); return (PyObject *)otherset; }