diff --git a/libssh2/src/kex.c b/libssh2/src/kex.c index 4ca9c34c7..72f8b704c 100644 --- a/libssh2/src/kex.c +++ b/libssh2/src/kex.c @@ -571,6 +571,11 @@ static int diffie_hellman_sha_algo(LIBSSH2_SESSION *session, #endif /* LIBSSH2DEBUG */ + if(!session->hostkey) { + ret = _libssh2_error(session, LIBSSH2_ERROR_PROTO, + "hostkey is NULL"); + goto clean_exit; + } if(session->hostkey->init(session, session->server_hostkey, session->server_hostkey_len, &session->server_hostkey_abstract)) {