Skip to content

Commit d868088

Browse files
committed
Update instr with proper return error handling
1 parent 5dd4304 commit d868088

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Modules/_cursesmodule.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2094,9 +2094,12 @@ PyCursesWindow_InStr(PyObject *op, PyObject *args)
20942094
}
20952095

20962096
if (rtn == ERR) {
2097-
_PyBytes_Resize(&result, 0);
2098-
} else {
2099-
_PyBytes_Resize(&result, rtn);
2097+
Py_DECREF(result);
2098+
return Py_GetConstant(Py_CONSTANT_EMPTY_BYTES);
2099+
}
2100+
2101+
if (_PyBytes_Resize(&result, rtn) < 0) {
2102+
return NULL;
21002103
}
21012104

21022105
return result;

0 commit comments

Comments
 (0)