Re: [patch] serious problem in pango_layout_set_text()



Hi,

Havoc Pennington <hp redhat com> writes:

> Sven Neumann <sven gimp org> writes:
> > 
> > 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).
> 
> All Pango and GTK functions require valid UTF-8; we aren't going to
> require error-checking on all of them. Invalid UTF-8 is considered a
> g_warning() or g_return_if_fail() situation.
> 
> Instead, you should g_utf8_validate() all text on its way into your
> app (e.g. when loading a file), and then assume all text in the app is
> valid UTF-8.

I've expected you or Owen would say this. Why are you validating the
string in pango_layout_set_text() then? If you decide not to add the
return value indicating success, please at least return the PangoLayout 
object in a sane state when bailing out with an error.


Salut, Sven




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