diff --git a/rts/Rendering/Fonts/CFontTexture.cpp b/rts/Rendering/Fonts/CFontTexture.cpp
index 53b0aec9c4..f7cb61a1ad 100644
--- a/rts/Rendering/Fonts/CFontTexture.cpp
+++ b/rts/Rendering/Fonts/CFontTexture.cpp
@@ -157,6 +157,7 @@ class FtLibraryHandler {
std::string configFmtVar = fmt::sprintf(configFmt, osFontsDir.data());
#else
static constexpr const char* configFmt = R"(fontcache)";
+ std::string configFmtVar = configFmt;
#endif
#ifdef _WIN32
@@ -169,7 +170,7 @@ class FtLibraryHandler {
if (res) {
#ifndef _WIN32
// add local cache after system config for linux
- FcConfigParseAndLoadFromMemory(config, reinterpret_cast(configFmt), FcTrue);
+ FcConfigParseAndLoadFromMemory(config, reinterpret_cast(configFmtVar.c_str()), FcTrue);
#endif
LOG_MSG("[%s] Using Fontconfig light init", false, __func__);
@@ -194,7 +195,7 @@ class FtLibraryHandler {
config = fcConfig;
// add our cache at the back of the new config.
- FcConfigParseAndLoadFromMemory(config, reinterpret_cast(configFmt), FcTrue);
+ FcConfigParseAndLoadFromMemory(config, reinterpret_cast(configFmtVar.c_str()), FcTrue);
} else {
LOG_MSG("%s config and fonts. No system fallbacks will be available", false, errprefix.c_str());
}