[Bug] Rtf2Text crash on coloring [sf#15]
Closed this issue · 4 comments
Reported by edmondm on 2006-08-30 19:22 UTC
RtfStyle has a nasty bug in the method
setForegroundColour()
The developer decided to check on the index of the
color to the size of the table, but someone forgot that
the size of the table could be 0, so assuming that the
table is populated, they go ahead and check and check
the index of that table.
There should be a condition check that
if (redTable->size() != 0)
{
....continue
This caused a segmentation fault on Linux, and we added
this code to get it working
Commented by andrewpunch on 2006-10-08 03:18 UTC
Logged In: YES
user_id=928005
The index should never reference a non-existent table entry
(in theory). However since the index value comes from the
RTF file itself it may refer to an empty table (as mentioned
here) or to an element which is not contained in the table.
This could be achieved in one of the following ways:
- assertions: this does not catch problems with corrupt RTF
files - exception: this catches problems with corrupt RTF files
but prevents the conversion of the rest of the text - log & continue: this catches the problem, logs the details
for further analysis and converts the rest of the text
Other changes:
- the red/green/blue colour tables should be combined
- the "default" colouring should be indicated by a separate
boolean value, not by a negative value in the red table
Updated by andrewpunch on 2006-10-08 03:18 UTC
- assigned_to: nobody --> andrewpunch
Commented by andrewpunch on 2006-10-15 13:16 UTC
Logged In: YES
user_id=928005
This entire section has been refactored:
- the red/green/blue values have been combined into a
separate class - the "default" values are encoded as booleans, not negative
colour values - note that the value supplied for the rtf command is
allowed to be negative, however size() returns an unsigned type
Still need to create a Log class to handle any problems that
may arise.
Updated by andrewpunch on 2006-11-11 23:15 UTC
- status: open --> closed