Skip to content

Commit 769ba15

Browse files
committed
add mem allocation guard
1 parent 12d4a5f commit 769ba15

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Modules/_cursesmodule.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1834,6 +1834,8 @@ PyCursesWindow_GetStr(PyObject *op, PyObject *args)
18341834
/* could make the buffer size larger/dynamic */
18351835
Py_ssize_t max_buf_size = 2048;
18361836
PyObject *result = PyBytes_FromStringAndSize(NULL, max_buf_size);
1837+
if (result == NULL)
1838+
return NULL;
18371839
char *buf = PyBytes_AS_STRING(result);
18381840

18391841
switch (PyTuple_Size(args)) {
@@ -2061,6 +2063,8 @@ PyCursesWindow_InStr(PyObject *op, PyObject *args)
20612063
/* could make the buffer size larger/dynamic */
20622064
Py_ssize_t max_buf_size = 2048;
20632065
PyObject *result = PyBytes_FromStringAndSize(NULL, max_buf_size);
2066+
if (result == NULL)
2067+
return NULL;
20642068
char *buf = PyBytes_AS_STRING(result);
20652069

20662070
switch (PyTuple_Size(args)) {

0 commit comments

Comments
 (0)