From 249adf2813e886b58f6846691f769634d1dfab4e Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Mon, 16 Aug 2021 20:50:50 -0300 Subject: [PATCH] Fixing segfault on 'non-session' log write. --- src/core/log.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/log.c b/src/core/log.c index db209ea..7272f88 100644 --- a/src/core/log.c +++ b/src/core/log.c @@ -109,7 +109,7 @@ LIB3270_EXPORT int lib3270_write_log(H3270 *session, const char *module, const c va_list arg_ptr; va_start(arg_ptr, fmt); - if(session->logfile) { + if(session && session->logfile) { logfile(session,module ? module : LIB3270_STRINGIZE_VALUE_OF(PRODUCT_NAME),0,fmt,arg_ptr); } else { loghandler(session,module ? module : LIB3270_STRINGIZE_VALUE_OF(PRODUCT_NAME),0,fmt,arg_ptr); @@ -123,7 +123,7 @@ LIB3270_EXPORT int lib3270_write_rc(H3270 *session, const char *module, int rc, va_list arg_ptr; va_start(arg_ptr, fmt); - if(session->logfile) { + if(session && session->logfile) { logfile(session,module ? module : LIB3270_STRINGIZE_VALUE_OF(PRODUCT_NAME),rc,fmt,arg_ptr); } else { loghandler(session,module ? module : LIB3270_STRINGIZE_VALUE_OF(PRODUCT_NAME),rc,fmt,arg_ptr); @@ -134,7 +134,7 @@ LIB3270_EXPORT int lib3270_write_rc(H3270 *session, const char *module, int rc, } LIB3270_EXPORT void lib3270_write_va_log(H3270 *session, const char *module, const char *fmt, va_list arg) { - if(session->logfile) { + if(session && session->logfile) { logfile(session,module ? module : LIB3270_STRINGIZE_VALUE_OF(PRODUCT_NAME),0,fmt,arg); } else { loghandler(session,module ? module : LIB3270_STRINGIZE_VALUE_OF(PRODUCT_NAME),0,fmt,arg); -- libgit2 0.21.2