Subject: Re: [libssh2] #182: Various memory leaks

Re: [libssh2] #182: Various memory leaks

From: libssh2 Trac <trac_at_libssh2.stuge.se>
Date: Wed, 23 Jun 2010 10:39:01 -0000

#182: Various memory leaks
-------------------------------+--------------------------------------------
  Reporter: john@… | Owner: bagder
      Type: defect | Status: assigned
  Priority: normal | Milestone: 1.2.6
 Component: API | Version: 1.2.6
Resolution: | Keywords:
    Blocks: | Blocked By:
-------------------------------+--------------------------------------------

Comment (by john@…):

 Two memory leaks if the socket is closed before closing the channel. Use
 the ssh2.c example program (diff -u ssh2.c)

 --- ssh2.c Thu Jun 10 07:36:02 2010
 +++ /usr2/other/libssh2/libssh2-1.2.6/example/ssh2.c Wed Jun 23
 11:30:29 2010
 @@ -230,6 +230,7 @@
       */

    skip_shell:
 +close(sock); /* close socket BEFORE doing anything else, simulate a close
 from server */
      if (channel) {
          libssh2_channel_free(channel);
          channel = NULL;

 Memory leaked,
 channel.c, line 160, '''session->open_channel'''
 channel.c, line 170, '''session->open_channel->channel_type'''

 Because the socket is now dead, any call to '''libssh2_channel_free'''
 will return -7 "Unable to send EOF on channel" and fails before releasing
 all the memory. You can't get beyond line 2293 and the call to
 '''_libssh2_channel_close'''
 I can find no line of code that sets '''session->socket_state''', which
 would be useful.

-- 
Ticket URL: <http://trac.libssh2.org/ticket/182#comment:3>
libssh2 <http://trac.libssh2.org/>
C library for writing portable SSH2 clients
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2010-06-23