]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-43108: Fix a reference leak in the curses module (GH-24420)
authorPablo Galindo <Pablogsal@gmail.com>
Tue, 2 Feb 2021 20:38:26 +0000 (20:38 +0000)
committerGitHub <noreply@github.com>
Tue, 2 Feb 2021 20:38:26 +0000 (20:38 +0000)
Misc/NEWS.d/next/Library/2021-02-02-20-23-31.bpo-43108.lqcCZ6.rst [new file with mode: 0644]
Modules/_cursesmodule.c

diff --git a/Misc/NEWS.d/next/Library/2021-02-02-20-23-31.bpo-43108.lqcCZ6.rst b/Misc/NEWS.d/next/Library/2021-02-02-20-23-31.bpo-43108.lqcCZ6.rst
new file mode 100644 (file)
index 0000000..8e45640
--- /dev/null
@@ -0,0 +1 @@
+Fixed a reference leak in the :mod:`curses` module. Patch by Pablo Galindo
index 4fcedc5fc4820f38998ff2c1d25f915f14c5498f..3df9f506052d3a5a7a8282bd75ac300e528932ce 100644 (file)
@@ -388,6 +388,7 @@ PyCurses_ConvertToString(PyCursesWindowObject *win, PyObject *obj,
         *bytes = obj;
         /* check for embedded null bytes */
         if (PyBytes_AsStringAndSize(*bytes, &str, NULL) < 0) {
+            Py_DECREF(obj);
             return 0;
         }
         return 1;
@@ -828,8 +829,9 @@ _curses_window_addstr_impl(PyCursesWindowObject *self, int group_left_1,
 #else
     strtype = PyCurses_ConvertToString(self, str, &bytesobj, NULL);
 #endif
-    if (strtype == 0)
+    if (strtype == 0) {
         return NULL;
+    }
     if (use_attr) {
         attr_old = getattrs(self->win);
         (void)wattrset(self->win,attr);