From c9effaa6e858a8076129ca5d1063e1f082e23846 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Tue, 7 Sep 2021 13:53:24 +0200 Subject: [PATCH] Fixed missing NULL checks in proxy logger macro --- include/freerdp/server/proxy/proxy_log.h | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/include/freerdp/server/proxy/proxy_log.h b/include/freerdp/server/proxy/proxy_log.h index a37db49b5..78de36ede 100644 --- a/include/freerdp/server/proxy/proxy_log.h +++ b/include/freerdp/server/proxy/proxy_log.h @@ -36,17 +36,21 @@ */ /* log macros that prepends session id and function name tp the log message */ -#define PROXY_LOG_INFO(_tag, _context, _format, ...) \ - WLog_INFO(TAG, "[SessionID=%s][%s]: " _format, _context->pdata->session_id, __FUNCTION__, \ +#define PROXY_LOG_INFO(_tag, _context, _format, ...) \ + WLog_INFO(TAG, "[SessionID=%s][%s]: " _format, \ + (_context && _context->pdata) ? _context->pdata->session_id : "null", __FUNCTION__, \ ##__VA_ARGS__) -#define PROXY_LOG_ERR(_tag, _context, _format, ...) \ - WLog_ERR(TAG, "[SessionID=%s][%s]: " _format, _context->pdata->session_id, __FUNCTION__, \ +#define PROXY_LOG_ERR(_tag, _context, _format, ...) \ + WLog_ERR(TAG, "[SessionID=%s][%s]: " _format, \ + (_context && _context->pdata) ? _context->pdata->session_id : "null", __FUNCTION__, \ ##__VA_ARGS__) -#define PROXY_LOG_DBG(_tag, _context, _format, ...) \ - WLog_DBG(TAG, "[SessionID=%s][%s]: " _format, _context->pdata->session_id, __FUNCTION__, \ +#define PROXY_LOG_DBG(_tag, _context, _format, ...) \ + WLog_DBG(TAG, "[SessionID=%s][%s]: " _format, \ + (_context && _context->pdata) ? _context->pdata->session_id : "null", __FUNCTION__, \ ##__VA_ARGS__) -#define PROXY_LOG_WARN(_tag, _context, _format, ...) \ - WLog_WARN(TAG, "[SessionID=%s][%s]: " _format, _context->pdata->session_id, __FUNCTION__, \ +#define PROXY_LOG_WARN(_tag, _context, _format, ...) \ + WLog_WARN(TAG, "[SessionID=%s][%s]: " _format, \ + (_context && _context->pdata) ? _context->pdata->session_id : "null", __FUNCTION__, \ ##__VA_ARGS__) #endif /* FREERDP_SERVER_PROXY_LOG_H */