From 916f0e9ab0a5e9a6d26044f78477d956dac5994c Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Sun, 28 Oct 2018 22:55:20 -0600 Subject: [PATCH] Fix a possible "double decref" in termios.tcgetattr(). (GH-10194) (cherry picked from commit 53835e92d315340444e3dd083b3f69a590b00e07) Co-authored-by: Zackery Spytz --- Modules/termios.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/termios.c b/Modules/termios.c index b78d33e6889a61..945d8e08e6a263 100644 --- a/Modules/termios.c +++ b/Modules/termios.c @@ -113,11 +113,11 @@ termios_tcgetattr(PyObject *self, PyObject *args) PyList_SetItem(v, 3, PyLong_FromLong((long)mode.c_lflag)); PyList_SetItem(v, 4, PyLong_FromLong((long)ispeed)); PyList_SetItem(v, 5, PyLong_FromLong((long)ospeed)); - PyList_SetItem(v, 6, cc); - if (PyErr_Occurred()){ + if (PyErr_Occurred()) { Py_DECREF(v); goto err; } + PyList_SetItem(v, 6, cc); return v; err: Py_DECREF(cc);