From 4fa488fb0159c629483b7994aa84e73926b132b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 13 Apr 2024 14:33:02 +0200 Subject: Merging upstream version 1:10.11.7. Signed-off-by: Daniel Baumann --- wsrep-lib/include/wsrep/logger.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'wsrep-lib/include/wsrep/logger.hpp') diff --git a/wsrep-lib/include/wsrep/logger.hpp b/wsrep-lib/include/wsrep/logger.hpp index a15873c2..4a9c46b1 100644 --- a/wsrep-lib/include/wsrep/logger.hpp +++ b/wsrep-lib/include/wsrep/logger.hpp @@ -86,7 +86,11 @@ namespace wsrep { if (logger_fn_) { - logger_fn_(level_, prefix_, oss_.str().c_str()); + // Prolong the lifetime of the string so it doesn't get + // destroyed right after evaluating c_str() and before + // completing the logger function call. + const std::string& tmp = oss_.str(); + logger_fn_(level_, prefix_, tmp.c_str()); } else { -- cgit v1.2.3