This is the mail archive of the
cygwin-patches@cygwin.com
mailing list for the Cygwin project.
[Patch] cygcheck (add_path): A little memory-leak.
- From: Bas van Gompel <cygwin-patches dot buzz at bavag dot tmfweb dot nl>
- To: cygwin-patches at cygwin dot com
- Date: Sun, 10 Oct 2004 08:36:36 +0200 (MET DST)
- Subject: [Patch] cygcheck (add_path): A little memory-leak.
- Organisation: Ehm...
- Reply-to: cygwin-patches mailing-list <cygwin-patches at cygwin dot com>
In cygcheck.cc, in function add_path, if paths[num_paths] was already
in the list, the mallocced memory was not released. The trivial (IMO)
patch follows...
ChangeLog-entry:
2004-10-10 Bas van Gompel <cygwin-patch.buzz@bavag.tmfweb.nl>
* cygcheck.cc (add_path): Don't leak memory when path is already in
``paths''.
--- src/winsup/utils/cygcheck.cc 9 Oct 2004 23:19:38 -0000 1.47
+++ src/winsup/utils/cygcheck.cc 10 Oct 2004 03:27:22 -0000
@@ -130,7 +130,10 @@ add_path (char *s, int maxlen)
*--e = 0;
for (int i = 1; i < num_paths; i++)
if (strcasecmp (paths[num_paths], paths[i]) == 0)
- return;
+ {
+ free (paths[num_paths]);
+ return;
+ }
num_paths++;
}
L8r,
Buzz.
--
) | | ---/ ---/ Yes, this | This message consists of true | I do not
-- | | / / really is | and false bits entirely. | mail for
) | | / / a 72 by 4 +-------------------------------+ any1 but
-- \--| /--- /--- .sigfile. | |perl -pe "s.u(z)\1.as." | me. 4^re