From 87fc75b23d4fa2fbebd4095ae893fcae8fe567b2 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sat, 23 Mar 2019 23:51:55 +0100 Subject: [PATCH] session_disconnect: don't zero state, just clear the right bit If we clear the entire field, the freeing of data in session_free() is skipped. Instead just clear the bit that risk making the code get stuck in the transport functions. Regression from 4d66f6762ca3fc45d9. Reported-by: dimmaq on github Fixes #338 Closes #340 --- src/session.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/session.c b/src/session.c index 8ff16719..2aa4d8b7 100644 --- a/src/session.c +++ b/src/session.c @@ -1168,7 +1168,7 @@ libssh2_session_disconnect_ex(LIBSSH2_SESSION *session, int reason, const char *desc, const char *lang) { int rc; - session->state = 0; + session->state &= ~LIBSSH2_STATE_EXCHANGING_KEYS; BLOCK_ADJUST(rc, session, session_disconnect(session, reason, desc, lang));