From: Fridrich S. <str...@us...> - 2008-07-18 13:12:01
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18778/src/lib Modified Files: WPG2Parser.cpp WPGBitmap.cpp Log Message: when dumping bitmaps and binary objects, don't crash when the filesystem of the current directory is read-only for the given user Index: WPG2Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG2Parser.cpp,v retrieving revision 1.70 retrieving revision 1.71 diff -u -d -r1.70 -r1.71 --- WPG2Parser.cpp 16 Jul 2008 14:10:59 -0000 1.70 +++ WPG2Parser.cpp 18 Jul 2008 13:11:57 -0000 1.71 @@ -1857,12 +1857,15 @@ #if DUMP_BINARY_DATA std::ostringstream filename; filename << "binarydump" << m_binaryId++ << ".bin"; - FILE *f = fopen(filename.str().c_str(), "w"); - const char *tmpBinaryBuffer = binaryData.getDataBuffer(); - const size_t tmpBufferSize = binaryData.size(); - for (size_t k = 0; k < tmpBufferSize; k++) - fprintf(f, "%c",tmpBinaryBuffer[k]); - fclose(f); + FILE *f = fopen(filename.str().c_str(), "wb"); + if (f) + { + const char *tmpBinaryBuffer = binaryData.getDataBuffer(); + const size_t tmpBufferSize = binaryData.size(); + for (size_t k = 0; k < tmpBufferSize; k++) + fprintf(f, "%c",tmpBinaryBuffer[k]); + fclose(f); + } #endif Index: WPGBitmap.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPGBitmap.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- WPGBitmap.cpp 16 Jul 2008 09:57:28 -0000 1.19 +++ WPGBitmap.cpp 18 Jul 2008 13:11:57 -0000 1.20 @@ -211,10 +211,13 @@ #if DUMP_BITMAP std::ostringstream filename; filename << "binarydump" << bitmapId++ << ".bmp"; - FILE *f = fopen("binarydump.bmp", "w"); - for (unsigned k = 0; k < tmpDIBFileSize; k++) - fprintf(f, "%c",tmpDIBBuffer[k]); - fclose(f); + FILE *f = fopen("binarydump.bmp", "wb"); + if (f) + { + for (unsigned k = 0; k < tmpDIBFileSize; k++) + fprintf(f, "%c",tmpDIBBuffer[k]); + fclose(f); + } #endif // Cleanup things before returning |