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

 
 

bug #34023: Memory leak in i18n.c

Submitter:  Stefan Israelsson Tampe <tampe>
Submitted:  Tue 16 Aug 2011 10:36:51 AM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  None
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

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

Good catch!  Fixed, I think.

Andy Wingo <wingo>
Group 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>
Group Member

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2011-08-16 wingo StatusNone Fixed
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.12.
    Corresponding source code