From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.lisp.guile.devel Subject: A minor fix in nl-langinfo Date: Sat, 09 Aug 2014 17:19:03 +0300 Message-ID: <83mwbdlp9k.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1407593982 13783 80.91.229.3 (9 Aug 2014 14:19:42 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 9 Aug 2014 14:19:42 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sat Aug 09 16:19:35 2014 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XG7Ub-0006iw-EW for guile-devel@m.gmane.org; Sat, 09 Aug 2014 16:19:33 +0200 Original-Received: from localhost ([::1]:56278 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XG7Ua-0005e2-VL for guile-devel@m.gmane.org; Sat, 09 Aug 2014 10:19:32 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:56317) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XG7UQ-0005dT-Cu for guile-devel@gnu.org; Sat, 09 Aug 2014 10:19:29 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XG7UI-0001HN-Sh for guile-devel@gnu.org; Sat, 09 Aug 2014 10:19:22 -0400 Original-Received: from mtaout22.012.net.il ([80.179.55.172]:49547) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XG7UI-0001HC-LG for guile-devel@gnu.org; Sat, 09 Aug 2014 10:19:14 -0400 Original-Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0NA100L00LZQJ600@a-mtaout22.012.net.il> for guile-devel@gnu.org; Sat, 09 Aug 2014 17:19:13 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NA100LOWMG17U80@a-mtaout22.012.net.il> for guile-devel@gnu.org; Sat, 09 Aug 2014 17:19:13 +0300 (IDT) X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Solaris 10 X-Received-From: 80.179.55.172 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:17317 Archived-At: This was in my sources for some time, but I somehow failed to send it. The problem is that nl_langinfo can return pointers to static buffers that are overwritten on subsequent calls. So we need to usher the value away before the next call. --- libguile/i18n.c~0 2014-08-08 17:05:57.262034100 +0300 +++ libguile/i18n.c 2014-08-09 13:04:19.901125000 +0300 @@ -1522,6 +1522,8 @@ SCM_DEFINE (scm_nl_langinfo, "nl-langinf else { c_result = nl_langinfo (c_item); + if (c_result != NULL) + c_result = strdup (c_result); codeset = nl_langinfo (CODESET); restore_locale_settings (&lsec_prev_locale); @@ -1532,12 +1534,11 @@ SCM_DEFINE (scm_nl_langinfo, "nl-langinf else { c_result = nl_langinfo (c_item); + if (c_result != NULL) + c_result = strdup (c_result); codeset = nl_langinfo (CODESET); } - if (c_result != NULL) - c_result = strdup (c_result); - unlock_locale_mutex (); if (c_result == NULL)