aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPablo Galindo <Pablogsal@gmail.com>2021-02-02 20:38:26 +0000
committerGitHub <noreply@github.com>2021-02-02 20:38:26 +0000
commitbb739ec922c6992a2be38f9fd3c544c2cc322dde (patch)
treedc054c57e95796f0cbd90e09de01a9edce372ea7 /Modules
parentbpo-41149: Fix a bug in threading that causes fals-y threads callables to fai... (diff)
downloadcpython-bb739ec922c6992a2be38f9fd3c544c2cc322dde.tar.gz
cpython-bb739ec922c6992a2be38f9fd3c544c2cc322dde.tar.bz2
cpython-bb739ec922c6992a2be38f9fd3c544c2cc322dde.zip
bpo-43108: Fix a reference leak in the curses module (GH-24420)
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_cursesmodule.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c
index 4fcedc5fc48..3df9f506052 100644
--- a/Modules/_cursesmodule.c
+++ b/Modules/_cursesmodule.c
@@ -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);