unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* A minor fix in nl-langinfo
@ 2014-08-09 14:19 Eli Zaretskii
  2014-08-10 14:22 ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2014-08-09 14:19 UTC (permalink / raw)
  To: guile-devel

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)





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-08-13 19:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-09 14:19 A minor fix in nl-langinfo Eli Zaretskii
2014-08-10 14:22 ` Eli Zaretskii
2014-08-12 20:15   ` Ludovic Courtès
2014-08-12 21:34     ` Mark H Weaver
2014-08-13 17:22       ` Mark H Weaver
2014-08-13 19:35         ` Ludovic Courtès

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).