From af1e591eeec4fbb47e1e050a562d5d5237d3c563 Mon Sep 17 00:00:00 2001 From: Will Cosgrove Date: Tue, 14 Feb 2023 09:13:04 -0800 Subject: [PATCH] Add NULL session check to _libssh2_error_flags() (#796) Don't dereference null if a null session happens to make it into _libssh2_error_flags() --- src/misc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/misc.c b/src/misc.c index 0c84fa4b..84d165c2 100644 --- a/src/misc.c +++ b/src/misc.c @@ -65,6 +65,12 @@ int _libssh2_error_flags(LIBSSH2_SESSION* session, int errcode, const char *errmsg, int errflags) { + if(session == NULL) { + if(errmsg != NULL) + fprintf(stderr, "Session is NULL, error: %s\n", errmsg); + return errcode; + } + if(session->err_flags & LIBSSH2_ERR_FLAG_DUP) LIBSSH2_FREE(session, (char *)session->err_msg);