Re: [patch] serious problem in pango_layout_set_text()



Sven Neumann <sven gimp org> writes:

> Hi,
> 
> attached is a patch that fixes a problem with pango_layout_set_text():
> If an invalid UTF8 string is set, this function used to spit out a 
> warning and returned in an inconsistent state (layout->text g_free'd)
> which causes the function to crash when being called the next time.
> 
> The patch adds a gboolean return value that indicates success of the
> operation to give the application programmer a chance to react to this
> problem (for example by displaying "[ Invalid UTF8 string ]" instead).

Havoc's points on this change are correct ... by g_warning() on a 
UTF-8 string, we are saying "your program is a buggy, fix it". There
is no point putting up a dialog saying "My program is buggy".

So, making the API return a value here is wrong. However, I wouldn't
object to a patch that didn't free the old value of layout->text
until after validating the new string ... if it's easy, we might
as well try to prevent a crash.

Regards,
                                        Owen




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]