From 0b2c54ad070f83fbae1ae6b20478f6706044edec Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko Date: Wed, 10 May 2023 02:27:49 +0200 Subject: [PATCH] ASYLUM: Fix use-after-free String goes out of scope but its c_str is still used. Keep a reference while we still need it. --- engines/asylum/system/text.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/engines/asylum/system/text.cpp b/engines/asylum/system/text.cpp index 07a20fc1d43..6b2c476343e 100644 --- a/engines/asylum/system/text.cpp +++ b/engines/asylum/system/text.cpp @@ -190,8 +190,12 @@ void Text::draw(const char *text) { return; } - if (_vm->getLanguage() == Common::HE_ISR) - text = Common::convertBiDiString(text, Common::kWindows1255).c_str(); + Common::String textRef; + + if (_vm->getLanguage() == Common::HE_ISR) { + textRef = Common::convertBiDiString(text, Common::kWindows1255); + text = textRef.c_str(); + } while (*text) { drawChar(text[0]); text++;