[Python-checkins] Fix a possible "double decref" in termios.tcgetattr(). (GH-10194)

Miss Islington (bot) webhook-mailer at python.org
Mon Oct 29 01:15:17 EDT 2018


https://github.com/python/cpython/commit/86a0f222cedc580413dd25d3565beef51ee24e5b
commit: 86a0f222cedc580413dd25d3565beef51ee24e5b
branch: 3.6
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2018-10-28T22:15:12-07:00
summary:

Fix a possible "double decref" in termios.tcgetattr(). (GH-10194)

(cherry picked from commit 53835e92d315340444e3dd083b3f69a590b00e07)

Co-authored-by: Zackery Spytz <zspytz at gmail.com>

files:
M Modules/termios.c

diff --git a/Modules/termios.c b/Modules/termios.c
index b78d33e6889a..945d8e08e6a2 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);



More information about the Python-checkins mailing list