Skip to content

Commit 90c6590

Browse files
authored
Merge pull request #709 from Jakuje/session-close
2 parents 65ea3a7 + a7131a1 commit 90c6590

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed crash when more operations were called after ``session.close()`` -- by :user:`Jakuje`.

src/pylibsshext/session.pyx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,8 +539,6 @@ cdef class Session(object):
539539
if self._libssh_session is not NULL:
540540
if libssh.ssh_is_connected(self._libssh_session):
541541
libssh.ssh_disconnect(self._libssh_session)
542-
libssh.ssh_free(self._libssh_session)
543-
self._libssh_session = NULL
544542

545543
def set_missing_host_key_policy(self, policy):
546544
"""The policy to use if the know host key is missing.

tests/unit/session_test.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ def test_make_session():
1313
assert Session()
1414

1515

16+
def test_make_session_close_connect():
17+
"""Make sure the session is usable after call to close()."""
18+
session = Session()
19+
session.close()
20+
error_msg = '^ssh connect failed: Hostname required$'
21+
with pytest.raises(LibsshSessionException, match=error_msg):
22+
session.connect()
23+
24+
1625
def test_session_connection_refused(free_port_num):
1726
"""Test that connecting to a missing service raises an error."""
1827
error_msg = '^ssh connect failed: Connection refused$'

0 commit comments

Comments
 (0)