File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1300,12 +1300,16 @@ RendererAgg::write_rgba(const Py::Tuple& args) {
13001300 const char *file_name = fileName.c_str ();
13011301 if ((fp = fopen (file_name, " wb" )) == NULL )
13021302 throw Py::RuntimeError ( Printf (" Could not open file %s" , file_name).str () );
1303- fwrite (pixBuffer, 1 , NUMBYTES, fp);
1303+ if (fwrite (pixBuffer, 1 , NUMBYTES, fp) != NUMBYTES) {
1304+ fclose (fp);
1305+ throw Py::RuntimeError ( Printf (" Error writing to file %s" , file_name).str () );
1306+ }
13041307 close_file = true ;
1305- fclose (fp);
13061308 } else if (PyFile_CheckExact (py_fileobj.ptr ())) {
13071309 fp = PyFile_AsFile (py_fileobj.ptr ());
1308- fwrite (pixBuffer, 1 , NUMBYTES, fp);
1310+ if (fwrite (pixBuffer, 1 , NUMBYTES, fp) != NUMBYTES) {
1311+ throw Py::RuntimeError ( " Error writing to file" );
1312+ }
13091313 } else {
13101314 PyObject* write_method = PyObject_GetAttrString (py_fileobj.ptr (), " write" );
13111315 if (!(write_method && PyCallable_Check (write_method))) {
You can’t perform that action at this time.
0 commit comments