1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-11-21 14:00:51 +03:00

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()
This commit is contained in:
Will Cosgrove
2023-02-14 09:13:04 -08:00
committed by GitHub
parent eefc06f2ef
commit af1e591eee

View File

@@ -65,6 +65,12 @@
int _libssh2_error_flags(LIBSSH2_SESSION* session, int errcode, int _libssh2_error_flags(LIBSSH2_SESSION* session, int errcode,
const char *errmsg, int errflags) 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) if(session->err_flags & LIBSSH2_ERR_FLAG_DUP)
LIBSSH2_FREE(session, (char *)session->err_msg); LIBSSH2_FREE(session, (char *)session->err_msg);