Changeset 46342 in webkit


Ignore:
Timestamp:
Jul 24, 2009 1:42:35 AM (15 years ago)
Author:
xan@webkit.org
Message:

2009-07-22 Xan Lopez <xlopez@igalia.com>

Reviewed by Jan Alonzo.

https://bugs.webkit.org/show_bug.cgi?id=25415
[GTK][ATK] Please implement support for get_text_at_offset

Fix confusion in g_substr between length in bytes and length in
characters. Was causing crashes in some situations when dealing
with non-ASCII text encoded as UTF8.

  • accessibility/gtk/AccessibilityObjectWrapperAtk.cpp: (g_substr):
Location:
trunk/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r46339 r46342  
     12009-07-24  Xan Lopez  <xlopez@igalia.com>
     2
     3        Reviewed by Jan Alonzo.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=25415
     6        [GTK][ATK] Please implement support for get_text_at_offset
     7
     8        Fix confusion in g_substr between length in bytes and length in
     9        characters. Was causing crashes in some situations when dealing
     10        with non-ASCII text encoded as UTF8.
     11
     12        * accessibility/gtk/AccessibilityObjectWrapperAtk.cpp:
     13        (g_substr):
     14
    1152009-07-24  Joseph Pecoraro  <joepeck02@gmail.com>
    216
  • trunk/WebCore/accessibility/gtk/AccessibilityObjectWrapperAtk.cpp

    r46125 r46342  
    572572static gchar* g_substr(const gchar* string, gint start, gint end)
    573573{
    574     gsize len = end - start + 1;
    575     gchar* output = static_cast<gchar*>(g_malloc0(len + 1));
    576     return g_utf8_strncpy(output, string +start, len);
     574    ASSERT(string);
     575    glong strLen = g_utf8_strlen(string, -1);
     576    if (start > strLen || end > strLen)
     577        return 0;
     578    gchar* startPtr = g_utf8_offset_to_pointer(string, start);
     579    gsize lenInBytes = g_utf8_offset_to_pointer(string, end) -  startPtr + 1;
     580    gchar* output = static_cast<gchar*>(g_malloc0(lenInBytes + 1));
     581    return g_utf8_strncpy(output, startPtr, end - start + 1);
    577582}
    578583
Note: See TracChangeset for help on using the changeset viewer.