bpo-33391: Fix refleak in set_symmetric_difference (GH-6670)
(cherry picked from commit 491bbedc209fea314a04cb3015da68fb0aa63238)
Co-authored-by: lekma <lekmalek@gmail.com>
diff --git a/Objects/setobject.c b/Objects/setobject.c
index 154be43..31da3db 100644
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -1710,8 +1710,10 @@
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;
}