bugGuile - Bugs: bug #34023, Memory leak in i18n.c

 
 

bug #34023: Memory leak in i18n.c

Submitted by:  Stefan Israelsson Tampe <tampe>
Submitted on:  Tue 16 Aug 2011 10:36:51 AM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Fixed
Privacy: PublicAssigned to: None
Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Tue 16 Aug 2011 11:23:12 AM UTC, comment #1:

Good catch! Fixed, I think.

Andy Wingo <wingo>
Project Administrator
Tue 16 Aug 2011 10:36:51 AM UTC, original submission:

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

Stefan Israelsson Tampe <tampe>
Project Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by wingo (Posted a comment)
  • -unavailable- added by tampe (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 16 Aug 2011 11:23:12 AM UTCwingoStatusNone=>Fixed
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1