guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A minor fix in nl-langinfo


From: Eli Zaretskii
Subject: Re: A minor fix in nl-langinfo
Date: Sun, 10 Aug 2014 17:22:35 +0300

> Date: Sat, 09 Aug 2014 17:19:03 +0300
> From: Eli Zaretskii <address@hidden>
> 
> 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

Sorry, that missed one more instance.  Please use this patch instead.

--- libguile/i18n.c~0   2014-08-08 17:05:57.262034100 +0300
+++ libguile/i18n.c     2014-08-10 17:20:52.073000000 +0300
@@ -1497,6 +1497,8 @@ SCM_DEFINE (scm_nl_langinfo, "nl-langinf
     {
 #ifdef USE_GNU_LOCALE_API
       c_result = nl_langinfo_l (c_item, c_locale);
+      if (c_result != NULL)
+       c_result = strdup (c_result);
       codeset = nl_langinfo_l (CODESET, c_locale);
 #else /* !USE_GNU_LOCALE_API */
       /* We can't use `RUN_IN_LOCALE_SECTION ()' here because the locale
@@ -1522,6 +1524,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 +1536,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)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]