From d69f17700a4b357ca549d8334d312cdbaa055454 Mon Sep 17 00:00:00 2001 From: Adam Wight Date: Sun, 19 Apr 2026 14:58:31 +0200 Subject: [PATCH] Simplify PATH override setenv is preferable because it doesn't carry the potential memory leak or null access if the launcher were to exec, for example. Note that we may want to prepend the release bin path rather than append? It would give more predictable behavior. The question is whether we want to allow the bin path to be overridden by a caller's environment or now. --- app/src/main/cpp/native-lib.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/app/src/main/cpp/native-lib.cpp b/app/src/main/cpp/native-lib.cpp index d816bb1..b5f6442 100644 --- a/app/src/main/cpp/native-lib.cpp +++ b/app/src/main/cpp/native-lib.cpp @@ -54,15 +54,11 @@ const char* startErlang(std::string root_dir, std::string log_dir) char* app_version = strtok(0, " "); if (!app_version) ERROR("Could not idenfity app version in start_erl.data file"); - std::string bin_dir = getenv("BINDIR"); - // keeping it static to keep the environment variable alive - char *path = getenv("PATH"); - // keeping it static to keep the environment variable alive - static std::string env_path = std::string("PATH=").append(path).append(":").append(bin_dir); + std::string env_path = std::string(getenv("PATH")).append(":").append(bin_dir); chdir(root_dir.c_str()); - putenv((char *)env_path.c_str()); + setenv("PATH", (char *)env_path.c_str(), 1); start_logger();