unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Stefan Israelsson Tampe <INVALID.NOREPLY@gnu.org>
To: Stefan Israelsson Tampe <stefan.itampe@gmail.com>, bug-guile@gnu.org
Subject: [bug #34023] Memory leak in i18n.c
Date: Tue, 16 Aug 2011 10:36:52 +0000	[thread overview]
Message-ID: <20110816-103651.sv78157.79991@savannah.gnu.org> (raw)
In-Reply-To: 

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/




             reply	other threads:[~2011-08-16 10:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-16 10:36 Stefan Israelsson Tampe [this message]
2011-08-16 11:23 ` [bug #34023] Memory leak in i18n.c Andy Wingo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110816-103651.sv78157.79991@savannah.gnu.org \
    --to=invalid.noreply@gnu.org \
    --cc=bug-guile@gnu.org \
    --cc=stefan.itampe@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).