summaryrefslogtreecommitdiffstats
path: root/Modules/_cursesmodule.c
diff options
context:
space:
mode:
authorZackery Spytz <zspytz@gmail.com>2019-11-17 17:10:13 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2019-11-17 17:10:13 (GMT)
commit2bc343417a4de83fa6998ff91303877734ecd366 (patch)
tree9342f53fa9415e22c1ccb7d73d08190547406fd1 /Modules/_cursesmodule.c
parent111772fc27cfe388bc060f019d68a3e33481ec65 (diff)
downloadcpython-2bc343417a4de83fa6998ff91303877734ecd366.zip
cpython-2bc343417a4de83fa6998ff91303877734ecd366.tar.gz
cpython-2bc343417a4de83fa6998ff91303877734ecd366.tar.bz2
bpo-36589: Fix the error handling in curses.update_lines_cols(). (GH-12766)
Return None instead of 1.
Diffstat (limited to 'Modules/_cursesmodule.c')
-rw-r--r--Modules/_cursesmodule.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c
index 29840b5..c2ce3a9 100644
--- a/Modules/_cursesmodule.c
+++ b/Modules/_cursesmodule.c
@@ -3837,15 +3837,18 @@ update_lines_cols(void)
}
/*[clinic input]
-_curses.update_lines_cols -> int
+_curses.update_lines_cols
[clinic start generated code]*/
-static int
+static PyObject *
_curses_update_lines_cols_impl(PyObject *module)
-/*[clinic end generated code: output=0345e7f072ea711a input=3a87760f7d5197f0]*/
+/*[clinic end generated code: output=423f2b1e63ed0f75 input=5f065ab7a28a5d90]*/
{
- return update_lines_cols();
+ if (!update_lines_cols()) {
+ return NULL;
+ }
+ Py_RETURN_NONE;
}
#endif
@@ -3929,8 +3932,10 @@ _curses_resizeterm_impl(PyObject *module, int nlines, int ncols)
result = PyCursesCheckERR(resizeterm(nlines, ncols), "resizeterm");
if (!result)
return NULL;
- if (!update_lines_cols())
+ if (!update_lines_cols()) {
+ Py_DECREF(result);
return NULL;
+ }
return result;
}
@@ -3966,8 +3971,10 @@ _curses_resize_term_impl(PyObject *module, int nlines, int ncols)
result = PyCursesCheckERR(resize_term(nlines, ncols), "resize_term");
if (!result)
return NULL;
- if (!update_lines_cols())
+ if (!update_lines_cols()) {
+ Py_DECREF(result);
return NULL;
+ }
return result;
}
#endif /* HAVE_CURSES_RESIZE_TERM */
@@ -4038,12 +4045,18 @@ _curses_start_color_impl(PyObject *module)
c = PyLong_FromLong((long) COLORS);
if (c == NULL)
return NULL;
- PyDict_SetItemString(ModDict, "COLORS", c);
+ if (PyDict_SetItemString(ModDict, "COLORS", c) < 0) {
+ Py_DECREF(c);
+ return NULL;
+ }
Py_DECREF(c);
cp = PyLong_FromLong((long) COLOR_PAIRS);
if (cp == NULL)
return NULL;
- PyDict_SetItemString(ModDict, "COLOR_PAIRS", cp);
+ if (PyDict_SetItemString(ModDict, "COLOR_PAIRS", cp) < 0) {
+ Py_DECREF(cp);
+ return NULL;
+ }
Py_DECREF(cp);
Py_RETURN_NONE;
} else {