diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2021-02-03 13:41:09 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-03 13:41:09 (GMT) |
commit | 12bfc595c49ef9681265407fe33b53b7a3623abc (patch) | |
tree | 267618c79e07281795dc5ad6cdb4db82ccc34c19 /Modules | |
parent | f02ef7afcf67db52f169f809a1b0babb80ec8370 (diff) | |
download | cpython-12bfc595c49ef9681265407fe33b53b7a3623abc.zip cpython-12bfc595c49ef9681265407fe33b53b7a3623abc.tar.gz cpython-12bfc595c49ef9681265407fe33b53b7a3623abc.tar.bz2 |
bpo-43108: Fix a reference leak in the curses module (GH-24420)
(cherry picked from commit bb739ec922c6992a2be38f9fd3c544c2cc322dde)
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_cursesmodule.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c index d129248..c84f838 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); |