summaryrefslogtreecommitdiff
path: root/libguile/i18n.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2011-08-16 13:16:21 +0200
committerAndy Wingo <wingo@pobox.com>2011-08-16 13:16:21 +0200
commit42f9581238b011d15114bfd31606cbda10574d17 (patch)
tree11726a7214f9ee80ecb130c96617b197f31ae8f7 /libguile/i18n.c
parente7a81c7acdc0501b3fca6cdd51eb05d4fe39d317 (diff)
downloadguile-42f9581238b011d15114bfd31606cbda10574d17.tar.gz
fix leak in get_current_locale()
* libguile/i18n.c (get_current_locale): Hold the locale name in a GC-managed string, not a mallocated string. Thanks to Stefan Israelsson Tampe for the report.
Diffstat (limited to 'libguile/i18n.c')
-rw-r--r--libguile/i18n.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/libguile/i18n.c b/libguile/i18n.c
index f9ec723a0..82e8b2a63 100644
--- a/libguile/i18n.c
+++ b/libguile/i18n.c
@@ -501,7 +501,6 @@ get_current_locale (SCM *result)
c_locale = scm_gc_malloc (sizeof (* c_locale), "locale");
-
lock_locale_mutex ();
c_locale->category_mask = LC_ALL_MASK;
@@ -509,20 +508,16 @@ get_current_locale (SCM *result)
current_locale = setlocale (LC_ALL, NULL);
if (current_locale != NULL)
- {
- c_locale->locale_name = strdup (current_locale);
- if (c_locale->locale_name == NULL)
- err = ENOMEM;
- }
+ c_locale->locale_name = scm_gc_strdup (current_locale);
else
err = EINVAL;
unlock_locale_mutex ();
- if (err)
- scm_gc_free (c_locale, sizeof (* c_locale), "locale");
- else
+ if (err == 0)
SCM_NEWSMOB (*result, scm_tc16_locale_smob_type, c_locale);
+ else
+ *result = SCM_BOOL_F;
return err;
}