From: Fridrich S. <str...@us...> - 2008-08-21 08:57:09
|
Update of /cvsroot/libwpg/libwpg/src/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21463/src/lib Modified Files: Tag: STABLE-0-1-0 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.58.2.16 retrieving revision 1.58.2.17 diff -u -d -r1.58.2.16 -r1.58.2.17 --- WPG2Parser.cpp 13 Aug 2008 07:44:19 -0000 1.58.2.16 +++ WPG2Parser.cpp 21 Aug 2008 08:57:04 -0000 1.58.2.17 @@ -899,22 +899,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 |