[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: Re: memory leak in awk applet
From: Denis Vlasenko <vda.linux () googlemail ! com>
Date: 2007-02-24 17:03:37
Message-ID: 200702241803.37090.vda.linux () googlemail ! com
[Download RAW message or body]
On Friday 23 February 2007 23:31, Dick Streefland wrote:
> I noticed that awk leaks memory when you read the $<N> variables
> repeatably. You can easily reproduce this with the following script:
>
> BEGIN{
> for (;;)
> {
> "echo foo" | getline;
> foo = $1;
> }
> }
>
> The problem is that the same string is allocated by bb_xstrdup() over
> and over again. The following patch stops the leak, but I'm not
> completely sure if it is the right fix:
>
> diff -pu busybox-1.4.1/editors/awk.c.orig busybox-1.4.1/editors/awk.c
> --- busybox-1.4.1/editors/awk.c.orig 2007-01-24 22:34:50.000000000 +0100
> +++ busybox-1.4.1/editors/awk.c 2007-02-23 23:28:36.000000000 +0100
> @@ -740,7 +740,7 @@ static var *copyvar(var *dest, const var
> {
> if (dest != src) {
> clrvar(dest);
> - dest->type |= (src->type & ~VF_DONTTOUCH);
> + dest->type |= (src->type & ~(VF_DONTTOUCH|VF_FSTR));
> dest->number = src->number;
> if (src->string)
> dest->string = xstrdup(src->string);
Looks ok to me. Applied, thanks!
--
vda
_______________________________________________
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic