bug-coreutils
[Top][All Lists]
Advanced

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

Re: [PATCH] sort.c: Fix minor memory leak, monthtab is never free'd if


From: Pádraig Brady
Subject: Re: [PATCH] sort.c: Fix minor memory leak, monthtab is never free'd if HAVE_NL_LANGINFO is defined and we're not in the "C" locale
Date: Tue, 16 Feb 2010 13:14:04 +0000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20100111 Thunderbird/3.0.1

On 16/02/10 09:26, Joey Degges wrote:
Hello,

At sort.c:1137, in inittables(), monthtab[i].name is alloc'd
if HAVE_NL_LANGINFO is defined and we're not in the "C" locale.

This patch adds the function freetables() which frees monthtab[i].name if
the appropriate conditions are met. freetables() is called at the end of
main().

From 75920d3d8e9632be1f7317d461b62ad14f3a12f0 Mon Sep 17 00:00:00 2001
From: Joey Degges<address@hidden>
Date: Mon, 15 Feb 2010 23:35:43 -0800
Subject: [PATCH 3/3] Fix minor memory leak: monthtab is never free'd if
HAVE_NL_LANGINFO is defined and we're not in the "C" locale.

I'm not sure about these, as you're modifying the heap
that you're just about to throw away anyway.
Perhaps stuff like this should be done only #ifdef lint?
For example, here is a similar patch for ls:

diff --git a/src/ls.c b/src/ls.c
index c55f525..7f99626 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -1457,6 +1457,14 @@ main (int argc, char **argv)
       hash_free (active_dir_set);
     }

+#ifdef lint
+  clear_files();
+  free (cwd_file);
+  free (filename_quoting_options);
+  free (dirname_quoting_options);
+  idcache_clear();
+#endif
+
   exit (exit_status);
 }

cheers,
Pádraig.




reply via email to

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