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

Re: [PATCH] connect: fix memory leak in ssh_select


On Thursday 31 October 2013 04:30:43 Jon Simons wrote:
> Hi,

Hey,
 
> Attached is a patch which fixes a leak in 'ssh_select'.  With the
> following test, I'm able to observe rapidly growing memory usage
> before the patch, and steady usage after.

thanks for the patch. I've written a unit test for this so we don't regress in 
future.

Pushed to the repository.


	-- andreas
 
> --
> 
> #include <libssh/libssh.h>
> #include <poll.h>
> #include <stdio.h>
> #include <time.h>
> 
> int main(int argc, char **argv) {
> 	int fd = open("/dev/null", 0x0);
> 	if (fd < 0)
> 		goto err;
> 
>         fd_set readfds;
> 	FD_SET(fd, &readfds);
> 
> 	while (1) {
> 		ssh_channel cin[1] = { NULL, };
> 		ssh_channel cout[1] = { NULL, };
> 		struct timeval tv = { .tv_sec = 0, .tv_usec = 1000 };
> 		ssh_select(cin, cout, fd + 1, &readfds, &tv);
> 	}
> 
> 	close(fd);
> err:
> 	printf("something went wrong\n");
> 	return 0;
> }
> 
> --
> Thanks,
> -Jon

-- 
Andreas Schneider                   GPG-ID: CC014E3D
www.cryptomilk.org                asn@xxxxxxxxxxxxxx


References:
[PATCH] connect: fix memory leak in ssh_selectJon Simons <jon@xxxxxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org