From 3a27b0857ef6d35911509eef88e567663bb0a0b6 Mon Sep 17 00:00:00 2001 From: Benjamin Peterson Date: Mon, 15 Aug 2016 22:01:41 -0700 Subject: [PATCH] do not decref value borrowed from list (closes #27774) --- Misc/NEWS | 2 ++ Modules/_sre.c | 4 +--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Misc/NEWS b/Misc/NEWS index b2f081c835..8c7acaf648 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -29,6 +29,8 @@ Core and Builtins Library ------- +- Issue #27774: Fix possible Py_DECREF on unowned object in _sre. + - Issue #27760: Fix possible integer overflow in binascii.b2a_qp. - Issue #27758: Fix possible integer overflow in the _csv module for large record diff --git a/Modules/_sre.c b/Modules/_sre.c index b1258eefc4..7b941ffdbc 100644 --- a/Modules/_sre.c +++ b/Modules/_sre.c @@ -3401,10 +3401,8 @@ match_groupdict(MatchObject* self, PyObject* args, PyObject* kw) if (!key) goto failed; value = match_getslice(self, key, def); - if (!value) { - Py_DECREF(key); + if (!value) goto failed; - } status = PyDict_SetItem(result, key, value); Py_DECREF(value); if (status < 0) -- 2.40.0