From: Fridrich S. <str...@us...> - 2008-08-21 08:56:50
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21199/src/lib Modified Files: WPG2Parser.cpp Log Message: avoiding a signedness/unsignedness issue Index: WPG2Parser.cpp =================================================================== RCS file: /cvsroot/libwpg/libwpg/src/lib/WPG2Parser.cpp,v retrieving revision 1.81 retrieving revision 1.82 diff -u -d -r1.81 -r1.82 --- WPG2Parser.cpp 13 Aug 2008 07:45:43 -0000 1.81 +++ WPG2Parser.cpp 21 Aug 2008 08:56:45 -0000 1.82 @@ -884,22 +884,25 @@ std::vector<double> positions; WPG_DEBUG_MSG((" Gradient colors : %d\n", count)); - for(unsigned i = 0; i < count; i++) + if (count > 0) // try not to run into signedness/unsignedness issues in second for cycle { - unsigned char red = readU8(); - unsigned char green = readU8(); - unsigned char blue = readU8(); - unsigned char alpha = readU8(); - libwpg::WPGColor color(red, green, blue, alpha); - colors.push_back(color); - WPG_DEBUG_MSG((" Color #%d (RGBA): %d %d %d %d\n", i+1, red, green, blue, alpha)); - } + for(unsigned i = 0; i < count; i++) + { + unsigned char red = readU8(); + unsigned char green = readU8(); + unsigned char blue = readU8(); + unsigned char alpha = readU8(); + libwpg::WPGColor color(red, green, blue, alpha); + colors.push_back(color); + WPG_DEBUG_MSG((" Color #%d (RGBA): %d %d %d %d\n", i+1, red, green, blue, alpha)); + } - for(unsigned j = 0; j < count-1; j++) - { - unsigned pos = readU16(); - positions.push_back(TO_DOUBLE(pos)); - WPG_DEBUG_MSG((" Position #%d : %d\n", j+1, pos)); + for(unsigned j = 0; j < count-1; j++) + { + unsigned pos = readU16(); + positions.push_back(TO_DOUBLE(pos)); + WPG_DEBUG_MSG((" Position #%d : %d\n", j+1, pos)); + } } // looks like Corel Presentations only create 2 colors gradient |