Ticket #246 (closed defect: fixed)

Opened 5 years ago

Last modified 4 years ago

libssh2_session_free does not release channels

Reported by: maxmtl Owned by:
Priority: normal Milestone: 1.4.3
Component: protocol Version: 1.4.2
Keywords: Cc:
Blocked By: Blocks:

Description

If libssh2_session_free is called without the channel being freed previously by libssh2_channel_free a memory leak could occur.

A mismatch of states variables in session_free() prevent the call to libssh2_channel_free function. session->state member is used instead of session->free_state.

It causes a leak of around 600 bytes on every connection on my systems (Linux, x64 and PPC).

The following patch correct the problem. Note that I am not sure of the state usage at line 861:

if (session->state & LIBSSH2_STATE_NEWKEYS)

I think it must stay as session->state.

(Debugging done under contract for Accedian Networks)

Attachments

libssh2-1.4.2-session_free_leak.patch (1.2 KB) - added by maxmtl 5 years ago.
Patch to correct the memory leak

Download all attachments as: .zip

Change History

Changed 5 years ago by maxmtl

Patch to correct the memory leak

comment:1 Changed 4 years ago by bagder

  • Resolution set to fixed
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.