summaryrefslogtreecommitdiffstats
path: root/Modules/_cursesmodule.c
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2023-08-26 23:24:40 (GMT)
committerGitHub <noreply@github.com>2023-08-26 23:24:40 (GMT)
commit3e2030371723e5fb7c9ccbe83cd980ce69cabc1a (patch)
tree16a5ba8999b1440a494153cd76e5a71a779ebb28 /Modules/_cursesmodule.c
parentbbdd8895a5aced4cd4e66a5c6e3471636f28df6b (diff)
downloadcpython-3e2030371723e5fb7c9ccbe83cd980ce69cabc1a.zip
cpython-3e2030371723e5fb7c9ccbe83cd980ce69cabc1a.tar.gz
cpython-3e2030371723e5fb7c9ccbe83cd980ce69cabc1a.tar.bz2
[3.12] gh-107913: Fix possible losses of OSError error codes (GH-107930) (#108523)
gh-107913: Fix possible losses of OSError error codes (GH-107930) Functions like PyErr_SetFromErrno() and SetFromWindowsErr() should be called immediately after using the C API which sets errno or the Windows error code. (cherry picked from commit 2b15536fa94d07e9e286826c23507402313ec7f4) Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Diffstat (limited to 'Modules/_cursesmodule.c')
-rw-r--r--Modules/_cursesmodule.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c
index 5691a41..743b9e3 100644
--- a/Modules/_cursesmodule.c
+++ b/Modules/_cursesmodule.c
@@ -3071,8 +3071,8 @@ _curses_getwin(PyObject *module, PyObject *file)
}
datalen = PyBytes_GET_SIZE(data);
if (fwrite(PyBytes_AS_STRING(data), 1, datalen, fp) != datalen) {
- Py_DECREF(data);
PyErr_SetFromErrno(PyExc_OSError);
+ Py_DECREF(data);
goto error;
}
Py_DECREF(data);