summaryrefslogtreecommitdiffstats
path: root/Modules/_cursesmodule.c
diff options
context:
space:
mode:
authorMatthias Klose <doko@ubuntu.com>2008-11-26 17:22:04 (GMT)
committerMatthias Klose <doko@ubuntu.com>2008-11-26 17:22:04 (GMT)
commit7e1b8faacc60fcd201b20a88e768c5ece2ee27f3 (patch)
treeda22e32a6f18bbdf99924cea9520f7118755856a /Modules/_cursesmodule.c
parent1ff110d8b3bfc204e401ac69576180f81cd6923a (diff)
downloadcpython-7e1b8faacc60fcd201b20a88e768c5ece2ee27f3.zip
cpython-7e1b8faacc60fcd201b20a88e768c5ece2ee27f3.tar.gz
cpython-7e1b8faacc60fcd201b20a88e768c5ece2ee27f3.tar.bz2
- Fix build failure of _cursesmodule.c building with -D_FORTIFY_SOURCE=2.
Diffstat (limited to 'Modules/_cursesmodule.c')
-rw-r--r--Modules/_cursesmodule.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c
index 4f99da5..3764f48 100644
--- a/Modules/_cursesmodule.c
+++ b/Modules/_cursesmodule.c
@@ -1857,6 +1857,7 @@ PyCurses_GetWin(PyCursesWindowObject *self, PyObject *stream)
int fd;
FILE *fp;
PyObject *data;
+ size_t datalen;
WINDOW *win;
PyCursesInitialised
@@ -1886,7 +1887,13 @@ PyCurses_GetWin(PyCursesWindowObject *self, PyObject *stream)
remove(fn);
return NULL;
}
- fwrite(PyBytes_AS_STRING(data), 1, PyBytes_GET_SIZE(data), fp);
+ datalen = PyBytes_GET_SIZE(data);
+ if (fwrite(PyBytes_AS_STRING(data), 1, datalen, fp) != datalen) {
+ Py_DECREF(data);
+ fclose(fp);
+ remove(fn);
+ return PyErr_SetFromErrnoWithFilename(PyExc_IOError, fn);
+ }
Py_DECREF(data);
fseek(fp, 0, 0);
win = getwin(fp);