This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFA] charset: sanitize if empty
- From: Tristan Gingold <gingold at adacore dot com>
- To: gdb-patches ml <gdb-patches at sourceware dot org>
- Date: Fri, 23 Oct 2009 15:29:11 +0200
- Subject: [RFA] charset: sanitize if empty
Hi,
it looks like allowed but nl_langinfo(CODESET) returns "" on Darwin.
Unfortunately GNU libiconv doesn't
like it at all and may enter into an infinite loop. I discovered this
while running the gdb testsuite.
The bug was reported to GNU libiconv and fixed, but I think it doesn't
hurt to sanitize more
auto_host_charset_name.
Tristan.
2009-10-23 Tristan Gingold <gingold@adacore.com>
* charset.c (_initialize_charset): Set a default value to
auto_host_charset_name if empty.
--- charset.c 25 Sep 2009 20:53:12 -0000 1.25
+++ charset.c 23 Oct 2009 13:26:01 -0000
@@ -818,8 +818,10 @@
#ifdef HAVE_LANGINFO_CODESET
auto_host_charset_name = nl_langinfo (CODESET);
/* Solaris will return `646' here -- but the Solaris iconv then
- does not accept this. */
- if (!strcmp (auto_host_charset_name, "646"))
+ does not accept this.
+ Darwin (and maybe FreeBSD) may return "" here, which GNU libiconv
+ doesn't like (infinite loop). */
+ if (!strcmp (auto_host_charset_name, "646") || !
*auto_host_charset_name)
auto_host_charset_name = "ASCII";
target_charset_name = auto_host_charset_name;