]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix a possible "double decref" in termios.tcgetattr(). (GH-10194)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 29 Oct 2018 05:15:12 +0000 (22:15 -0700)
committerGitHub <noreply@github.com>
Mon, 29 Oct 2018 05:15:12 +0000 (22:15 -0700)
(cherry picked from commit 53835e92d315340444e3dd083b3f69a590b00e07)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
Modules/termios.c

index b78d33e6889a61654caaf1b65ca6a343cda8fe67..945d8e08e6a263d79ba9e4b4c923dc689ec78d6a 100644 (file)
@@ -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);