From 6a56790e0b50846f1f968e48c3a321c148b5e6cd Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Wed, 2 May 2018 02:50:48 -0700 Subject: [PATCH] bpo-33391: Fix refleak in set_symmetric_difference (GH-6670) (cherry picked from commit 491bbedc209fea314a04cb3015da68fb0aa63238) Co-authored-by: lekma --- .../2018-05-02-08-36-03.bpo-33391.z4a7rb.rst | 1 + Objects/setobject.c | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2018-05-02-08-36-03.bpo-33391.z4a7rb.rst 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 47db6b245ca..ce35aa2a0cd 100644 --- a/Objects/setobject.c +++ b/Objects/setobject.c @@ -1744,8 +1744,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; }