Bug 3252 - incorrect usage of bind_textdomain_codeset()
Summary: incorrect usage of bind_textdomain_codeset()
Status: RESOLVED FIXED
Alias: None
Product: UIM
Classification: Unclassified
Component: libuim (show other bugs)
Version: unspecified
Hardware: x86 (IA32) All
: high major
Assignee: uim-bugs
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-05-09 19:37 UTC by YONETANI Tomokazu
Modified: 2005-05-30 02:50 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description YONETANI Tomokazu 2005-05-09 19:37:56 UTC
In uim-0.4.4 and the later version, there is an incorrect usage of
bind_textdomain_codeset() in its macro definition in uim/context.h .
The macros in question are:

UIM_SWITCH_TEXTDOMAIN_CODESET
UIM_RESTORE_TEXTDOMAIN_CODESET

The former calls bind_textdomain_codeset() to get the current codeset
and set it to a local pointer orig_encoding (defined by another macro),
then call bind_textdomain_codeset() to set the new codeset for the specified
textdomain. The latter restores the previous codeset for the textdomain
by calling bind_textdomain_codeset() with orig_encoding as its argument.

According to the man page of bind_textdomain_codeset() function,
the return value is valid until the next call to the same function
(I'm using gettext-0.14.1, but the description of the validity of return
value hasn't been changed since gettext-0.11.5, so this isn't new).
That is, the original codeset pointed to by orig_encoding is no longer
valid by the time UIM_RESTORE_TEXTDOMAIN_CODESET is used, because it's
the third call to bind_textdomain_codeset() when it tries to restore
the codeset. This sometimes results in referencing a free'ed memory
location and segmentation fault, because the private function(in libintl)
set_binding_values() frees the previously returned string before registering
the new codeset string.
(this is a slightly modified version of FreeBSD PR ports/80755)
Comment 1 TOKUNAGA Hiroyuki 2005-05-10 19:41:27 UTC
Though I've not yet checked this bug, I'll investigate and fix the bug until 0.4.7.
Thanks for your report!
Comment 2 YONETANI Tomokazu 2005-05-10 19:55:10 UTC
(In reply to comment #1)
> Though I've not yet checked this bug, I'll investigate and
> fix the bug until 0.4.7.

Ugh, I forgot attaching the patch I've submitted to FreeBSD PR
(got no response yet):
http://les.ath.cx/patches/patch-uim-context.h
Comment 3 Etsushi Kato 2005-05-30 19:50:56 UTC
Fixed in revision 848.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.