From: <md...@us...> - 2008-04-29 14:24:06
|
Revision: 5097 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5097&view=rev Author: mdboom Date: 2008-04-29 07:22:48 -0700 (Tue, 29 Apr 2008) Log Message: ----------- Check the return value of fwrite (and eliminate gcc 4.x warnings) Modified Paths: -------------- trunk/matplotlib/src/_backend_agg.cpp Modified: trunk/matplotlib/src/_backend_agg.cpp =================================================================== --- trunk/matplotlib/src/_backend_agg.cpp 2008-04-29 13:35:47 UTC (rev 5096) +++ trunk/matplotlib/src/_backend_agg.cpp 2008-04-29 14:22:48 UTC (rev 5097) @@ -1300,12 +1300,16 @@ const char *file_name = fileName.c_str(); if ((fp = fopen(file_name, "wb")) == NULL) throw Py::RuntimeError( Printf("Could not open file %s", file_name).str() ); - fwrite(pixBuffer, 1, NUMBYTES, fp); + if (fwrite(pixBuffer, 1, NUMBYTES, fp) != NUMBYTES) { + fclose(fp); + throw Py::RuntimeError( Printf("Error writing to file %s", file_name).str() ); + } close_file = true; - fclose(fp); } else if (PyFile_CheckExact(py_fileobj.ptr())) { fp = PyFile_AsFile(py_fileobj.ptr()); - fwrite(pixBuffer, 1, NUMBYTES, fp); + if (fwrite(pixBuffer, 1, NUMBYTES, fp) != NUMBYTES) { + throw Py::RuntimeError( "Error writing to file" ); + } } else { PyObject* write_method = PyObject_GetAttrString(py_fileobj.ptr(), "write"); if (!(write_method && PyCallable_Check(write_method))) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |