URL:
<http://savannah.gnu.org/bugs/?34023>
Summary: Memory leak in i18n.c
Project: Guile
Submitted by: tampe
Submitted on: Tue 16 Aug 2011 10:36:51 AM GMT
Category: None
Severity: 3 - Normal
Item Group: None
Status: None
Privacy: Public
Assigned to: None
Open/Closed: Open
Discussion Lock: Any
_______________________________________________________
Details:
This looks strange:
Consider this in i18.c,
get_current_locale (SCM *result)
{
int err = 0;
scm_t_locale c_locale;
const char *current_locale;
(1) c_locale = scm_gc_malloc (sizeof (* c_locale), "locale");
lock_locale_mutex ();
c_locale->category_mask = LC_ALL_MASK;
c_locale->base_locale = SCM_UNDEFINED;
current_locale = setlocale (LC_ALL, NULL);
if (current_locale != NULL)
{
(2) c_locale->locale_name = strdup (current_locale);
if (c_locale->locale_name == NULL)
err = ENOMEM;
}
else
err = EINVAL;
unlock_locale_mutex ();
if (err)
scm_gc_free (c_locale, sizeof (* c_locale), "locale");
else
SCM_NEWSMOB (*result, scm_tc16_locale_smob_type, c_locale);
return err;
}
(1) c_locale is allocated managed by gc and not pointerless.
e.g. members should as well be gc allocated
(2) a memeber of c_locale is setted to a malloced memory region
should it be scm_strdup?
/Stefan
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?34023>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/