From 413c8c833d11329579716b9c80eb6b748740d5bf Mon Sep 17 00:00:00 2001 From: matt335672 <30179339+matt335672@users.noreply.github.com> Date: Tue, 6 Aug 2024 13:01:08 +0100 Subject: [PATCH] Add guards to xrdp_mm_module_cleanup Adds pointer checks to less commonly used codepaths to prevent a possible SEGV on process shutdown. --- xrdp/xrdp_mm.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/xrdp/xrdp_mm.c b/xrdp/xrdp_mm.c index 16549464..fa4da6ff 100644 --- a/xrdp/xrdp_mm.c +++ b/xrdp/xrdp_mm.c @@ -131,10 +131,15 @@ xrdp_mm_module_cleanup(struct xrdp_mm *self) self->mod = 0; self->mod_handle = 0; - if (self->wm->hide_log_window) + if (self->wm && self->wm->hide_log_window) { - /* make sure autologin is off */ - self->wm->session->client_info->rdp_autologin = 0; + /* make sure autologin is off. + * Check pointers are valid in case we're ending the process */ + if (self->wm->session != NULL && + self->wm->session->client_info != NULL) + { + self->wm->session->client_info->rdp_autologin = 0; + } xrdp_wm_set_login_state(self->wm, WMLS_RESET); /* reset session */ }