[Python-3000-checkins] r67394 - in python/branches/py3k: Misc/NEWS Modules/_cursesmodule.c

matthias.klose python-3000-checkins at python.org
Wed Nov 26 18:22:04 CET 2008


Author: matthias.klose
Date: Wed Nov 26 18:22:04 2008
New Revision: 67394

Log:
- Fix build failure of _cursesmodule.c building with -D_FORTIFY_SOURCE=2.


Modified:
   python/branches/py3k/Misc/NEWS
   python/branches/py3k/Modules/_cursesmodule.c

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Wed Nov 26 18:22:04 2008
@@ -19,6 +19,8 @@
 - Issue #4367: Python would segfault during compiling when the unicodedata
   module couldn't be imported and \N escapes were present.
 
+- Fix build failure of _cursesmodule.c building with -D_FORTIFY_SOURCE=2.
+
 Library
 -------
 

Modified: python/branches/py3k/Modules/_cursesmodule.c
==============================================================================
--- python/branches/py3k/Modules/_cursesmodule.c	(original)
+++ python/branches/py3k/Modules/_cursesmodule.c	Wed Nov 26 18:22:04 2008
@@ -1857,6 +1857,7 @@
   int fd;
   FILE *fp;
   PyObject *data;
+  size_t datalen;
   WINDOW *win;
 
   PyCursesInitialised
@@ -1886,7 +1887,13 @@
     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);


More information about the Python-3000-checkins mailing list