summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2021-02-15 10:43:52 -0800
committerGitHub <noreply@github.com>2021-02-15 18:43:52 +0000
commitede1ff226c9ef4efd053109c69b4e33f75b2b17b (patch)
tree5ff4164ddabd60e5b10f9264a24983977e3d2328
parent[3.8] bpo-42967: only use '&' as a query string separator (GH-24297) (#24529) (diff)
downloadcpython-ede1ff226c9ef4efd053109c69b4e33f75b2b17b.tar.gz
cpython-ede1ff226c9ef4efd053109c69b4e33f75b2b17b.tar.bz2
cpython-ede1ff226c9ef4efd053109c69b4e33f75b2b17b.zip
bpo-43108: Fix a reference leak in the curses module (GH-24420) (GH-24429)
(cherry picked from commit bb739ec922c6992a2be38f9fd3c544c2cc322dde) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com> Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
-rw-r--r--Misc/NEWS.d/next/Library/2021-02-02-20-23-31.bpo-43108.lqcCZ6.rst1
-rw-r--r--Modules/_cursesmodule.c4
2 files changed, 4 insertions, 1 deletions
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
index 00000000000..8e45640bcea
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2021-02-02-20-23-31.bpo-43108.lqcCZ6.rst
@@ -0,0 +1 @@
+Fixed a reference leak in the :mod:`curses` module. Patch by Pablo Galindo
diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c
index 0f35cdd2861..35070d94e0c 100644
--- a/Modules/_cursesmodule.c
+++ b/Modules/_cursesmodule.c
@@ -365,6 +365,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;
@@ -679,8 +680,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);