Fix stack-use-after-scope reading QT_QPA_PLATFORM env var

Setting QT_QPA_PLATFORM with putenv from a local variable
causes the environment to later still refer to it when it's out of scope.
Use setenv instead, as it copies the values provided.
This commit is contained in:
Stefano Bonicatti
2025-02-05 15:40:13 +01:00
committed by Baldur Karlsson
parent 9c8bb99494
commit a0e52feba1
+1 -2
View File
@@ -203,10 +203,9 @@ int main(int argc, char *argv[])
{
const char *qpa_plat = getenv("QT_QPA_PLATFORM");
// if not set or empty, force non-wayland to help go through backwards compatibility path on wayland.
char env_set[] = "QT_QPA_PLATFORM=xcb\0";
if(!qpa_plat || qpa_plat[0] == 0)
{
putenv(env_set);
setenv("QT_QPA_PLATFORM", "xcb", 1);
envChanged = true;
}
}