From fddd7005693d4ce59abc48bc53049eab59dc2dd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Wed, 4 Nov 2026 14:17:54 -0800 Subject: [PATCH] bx::Error::getMessage() returns by value: the message is a local before %S. Closes #4115. (#4116) --- src/bgfx_p.h | 4 +++- tools/texturev/texturev.cpp | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/bgfx_p.h b/src/bgfx_p.h index ee8ea89a7..842cd9610 100644 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -113,10 +113,12 @@ namespace bgfx if (!BX_IGNORE_C4127(_condition) ) \ { \ BX_ERROR_SET(_err, _result, _msg); \ + const bx::StringLiteral bgfxErrorMsg = _err->getMessage(); \ + BX_UNUSED(bgfxErrorMsg); \ BX_TRACE("%S: 0x%08x '%S' - " _format \ , &bxErrorScope.getName() \ , _err->get().code \ - , &_err->getMessage() \ + , &bgfxErrorMsg \ , ##__VA_ARGS__ \ ); \ return; \ diff --git a/tools/texturev/texturev.cpp b/tools/texturev/texturev.cpp index ee141ca4f..4b3b4dbde 100644 --- a/tools/texturev/texturev.cpp +++ b/tools/texturev/texturev.cpp @@ -1477,7 +1477,8 @@ void associate() } else { - bx::printf("Failed to associate MIME type image/%S (error: \"%S\")!\n", &_ext, &err.getMessage() ); + const bx::StringLiteral msg = err.getMessage(); + bx::printf("Failed to associate MIME type image/%S (error: \"%S\")!\n", &_ext, &msg); } bx::stringPrintf(mimeType, "image/%S;", &_ext); @@ -1514,7 +1515,8 @@ void associate() } else { - bx::printf("Failed to create texturev desktop entry (error: \"%S\")! Permissions (try sudo)?!\n", &err.getMessage() ); + const bx::StringLiteral msg = err.getMessage(); + bx::printf("Failed to create texturev desktop entry (error: \"%S\")! Permissions (try sudo)?!\n", &msg); } #endif // BX_PLATFORM_WINDOWS }