]> granicus.if.org Git - python/commitdiff
Fix a possible "double decref" in termios.tcgetattr(). (GH-10194)
authorZackery Spytz <zspytz@gmail.com>
Mon, 29 Oct 2018 04:55:20 +0000 (22:55 -0600)
committerSerhiy Storchaka <storchaka@gmail.com>
Mon, 29 Oct 2018 04:55:20 +0000 (06:55 +0200)
Modules/termios.c

index b4aa77f89764a0a85f9e4ae3a80d20d49d8a08c8..7601b68afda3c9ff77980781b84e5b3f43ea03fd 100644 (file)
@@ -119,11 +119,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);