From 6682868b87ce442383bfa98d305150de658ae87c Mon Sep 17 00:00:00 2001 From: Alexei Pastuchov Date: Sat, 18 Jul 2026 05:14:51 +0200 Subject: [PATCH] Guard gearman_log_error() against NULL error strings gearman_universal_st::error() returns nullptr when the error code is GEARMAN_SUCCESS, but gearman_log_error() passed that value straight to the user-supplied log_fn callback with no NULL check. Every other logging path in this file formats into a local buffer via vsnprintf and can never hand log_fn a NULL pointer, so this was the one path that could crash a log_fn implementation that assumes a valid string (e.g. strlen/fprintf("%s", line)). Signed-off-by: Alexei Pastuchov --- libgearman/log.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libgearman/log.cc b/libgearman/log.cc index ea35ab3de..6fac29150 100644 --- a/libgearman/log.cc +++ b/libgearman/log.cc @@ -79,7 +79,10 @@ void gearman_log_error(gearman_universal_st& state, gearman_verbose_t verbose) { if (state.log_fn) { - state.log_fn(state.error(), verbose, state.log_context); + if (const char *line= state.error()) + { + state.log_fn(line, verbose, state.log_context); + } } } }