From: Fridrich S. <str...@us...> - 2008-07-18 13:12:23
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19149/src/lib Modified Files: Tag: STABLE-0-1-0 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.58.2.9 retrieving revision 1.58.2.10 diff -u -d -r1.58.2.9 -r1.58.2.10 --- WPG2Parser.cpp 9 Jul 2008 14:45:58 -0000 1.58.2.9 +++ WPG2Parser.cpp 18 Jul 2008 13:12:17 -0000 1.58.2.10 @@ -1871,12 +1871,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.11.2.5 retrieving revision 1.11.2.6 diff -u -d -r1.11.2.5 -r1.11.2.6 --- WPGBitmap.cpp 9 Jul 2008 14:45:58 -0000 1.11.2.5 +++ WPGBitmap.cpp 18 Jul 2008 13:12:17 -0000 1.11.2.6 @@ -212,10 +212,13 @@ #if DUMP_BITMAP std::ostringstream filename; filename << "binarydump" << bitmapId++ << ".bmp"; - FILE *f = fopen("binarydump.bmp", "w"); - for (int 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 |