Subject: Re: [libssh2] Memory leak in payload

Re: [libssh2] Memory leak in payload

From: Daniel Stenberg <>
Date: Wed, 14 Mar 2007 23:13:56 +0100 (CET)

On Wed, 14 Mar 2007, Dan Fandrich wrote:

> I've spotted (thanks to valgrind) what looks like a memory leak in libssh2.
> The pointer session->packet->payload (a.k.a. p->payload) is allocated in
> libssh2_packet_read(), but it doesn't seem to be freed anywhere in the
> non-error, non-compression path.

Ouch. While I wrote the current version of libssh2_packet_read(), I do believe
the current approach was used before as well and libssh2_packet_add() does
seem to assume an allocated pointer getting passed in as it frees it on
several places when an error occurs and it uses the mere pointer when it adds
it to its queue...

So it seems it gets lost when in the queue or possibly not freed when getting
pulled out from the queue at a later time.

Sara or anyone else? Care to explain how that memory is supposed to be freed?

Dan, does this problem occur when running one of the sample apps against a
plain standard OpenSSH server or does it require anything particular?

Take Surveys. Earn Cash. Influence the Future of IT
Join's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
libssh2-devel mailing list
Received on 2007-03-14