After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 355435 - Invalid calls to pango_map_get_engine()
Invalid calls to pango_map_get_engine()
Status: RESOLVED FIXED
Product: pango
Classification: Platform
Component: general
1.14.x
Other All
: Normal normal
: ---
Assigned To: pango-maint
pango-maint
Depends on:
Blocks:
 
 
Reported: 2006-09-11 13:59 UTC by Theppitak Karoonboonyanan
Modified: 2006-09-11 21:06 UTC
See Also:
GNOME target: ---
GNOME version: 2.15/2.16


Attachments
Proposed patch (3.38 KB, patch)
2006-09-11 14:10 UTC, Theppitak Karoonboonyanan
none Details | Review

Description Theppitak Karoonboonyanan 2006-09-11 13:59:00 UTC
The prototype for pango_map_get_engine() is:

PangoEngine *  pango_map_get_engine  (PangoMap            *map,
                                      PangoScript          script);

But the calls to this function in pango_get_log_attrs() are:

  range_engine = (PangoEngineLang*) pango_map_get_engine (lang_map,
                                                          g_utf8_get_char (text));

and:

      analysis.lang_engine =
        (PangoEngineLang*) pango_map_get_engine (lang_map,
                                                 g_utf8_get_char (pos));

where the second argument is passed as a gunichar, instead of PangoScript as actually required.

As a result, the default engine, rather than the engine for the text itself, seems to always be used in random places, such as the handling of word movements in GtkTextView. For example, when installing pango-libthai language engine [1], which provides Pango attributes at Thai word boundaries, this code prevents proper caret movements by word from working (because the libthai engine is never called).

By a brief grep on source codes, this kind of error also appears in pangofc-font.c, pangowin32.c and pangox.c. But I have not verified the effects of such cases.

[1] http://libthai.sourceforge.net/
Comment 1 Theppitak Karoonboonyanan 2006-09-11 14:10:56 UTC
Created attachment 72552 [details] [review]
Proposed patch
Comment 2 Behdad Esfahbod 2006-09-11 14:54:42 UTC
Disaster!
We should add an assertion in the function.
Comment 3 Behdad Esfahbod 2006-09-11 21:06:18 UTC
2006-09-11  Behdad Esfahbod  <behdad@gnome.org>

        Bug 355435 – Invalid calls to pango_map_get_engine()
        Patch from Theppitak Karoonboonyanan

        * pango/break.c (pango_get_log_attrs):
        * pango/pango-renderer.c (add_underline):
        * pango/pangofc-font.c (pango_fc_font_find_shaper):
        * pango/pangowin32.c (pango_win32_font_find_shaper):
        * pango/pangox.c (pango_x_font_find_shaper):
        Pass a PangoScript to pango_map_get_engine, not a gunichar!