pspp-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: another memory leak, with patch


From: John Darrington
Subject: Re: another memory leak, with patch
Date: Tue, 25 Nov 2008 15:43:31 +0900
User-agent: Mutt/1.5.18 (2008-05-17)

Looks fine to me.

On Mon, Nov 24, 2008 at 10:12:57PM -0800, Ben Pfaff wrote:
     valgrind reports:
     
         ==3634== 194 (102 direct, 92 indirect) bytes in 4 blocks are 
definitely lost in loss record 12 of 15
         ==3634==    at 0x4022AB8: malloc (vg_replace_malloc.c:207)
         ==3634==    by 0x40E37C1: xmalloc (xmalloc.c:49)
         ==3634==    by 0x414FDA1: get_system_decimal (i18n.c:237)
         ==3634==    by 0x413D944: settings_init (settings.c:153)
         ==3634==    by 0x804A808: main (main.c:109)
     
     Proposed fix below.  Comments?
     
     commit 17aed102d2f038e56b33eb0124652e15a21631e6
     Author: Ben Pfaff <address@hidden>
     Date:   Mon Nov 24 22:12:01 2008 -0800
     
         Fix memory leak in get_system_decimal().
     
     diff --git a/src/libpspp/i18n.c b/src/libpspp/i18n.c
     index bda2676..db85121 100644
     --- a/src/libpspp/i18n.c
     +++ b/src/libpspp/i18n.c
     @@ -225,24 +225,24 @@ i18n_done (void)
      char
      get_system_decimal (void)
      {
     -  char *radix_char = NULL;
     +  char radix_char;
      
        char *ol = setlocale (LC_NUMERIC, NULL);
        setlocale (LC_NUMERIC, "");
      
      #if HAVE_NL_LANGINFO
     -  radix_char = nl_langinfo (RADIXCHAR);
     +  radix_char = nl_langinfo (RADIXCHAR)[0];
      #else
        {
     -    char *buf = xmalloc (10);
     -    snprintf (buf, 10, "%f", 2.5);
     -    radix_char = &buf[1];
     +    char buf[10];
     +    snprintf (buf, sizeof buf, "%f", 2.5);
     +    radix_char = buf[1];
        }
      #endif
      
        /* We MUST leave LC_NUMERIC untouched, since it would
           otherwise interfere with data_{in,out} */
        setlocale (LC_NUMERIC, ol);
     -  return *radix_char;
     +  return radix_char;
      }
      
     
     -- 
     Ben Pfaff 
     http://benpfaff.org
     
     
     _______________________________________________
     pspp-dev mailing list
     address@hidden
     http://lists.gnu.org/mailman/listinfo/pspp-dev

-- 
PGP Public key ID: 1024D/2DE827B3 
fingerprint = 8797 A26D 0854 2EAB 0285  A290 8A67 719C 2DE8 27B3
See http://pgp.mit.edu or any PGP keyserver for public key.


Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]