From e15fb0dc38645ae166d44849a106f6363359ec27 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 1 Apr 2022 20:50:28 +0200 Subject: [PATCH] Fix unset of LIBRARY_PATH environment variable see also 82d491cb8080acee348306e708375a8d52bab36b --- libs/pbd/system_exec.cc | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/libs/pbd/system_exec.cc b/libs/pbd/system_exec.cc index 140340f55f..574a1aa5b7 100644 --- a/libs/pbd/system_exec.cc +++ b/libs/pbd/system_exec.cc @@ -596,19 +596,23 @@ extern char **environ; void SystemExec::make_envp (bool supress_ld_env) { - int i = 0; - envp = (char **) calloc(1, sizeof(char*)); + int i = 0, j = 0; + envp = (char **) calloc (1, sizeof(char*)); /* copy current environment */ for (i = 0; environ[i]; ++i) { -#ifndef __APPLE__ - if (supress_ld_env && 0 == strncmp (environ[i], "LD_LIBRARY_PATH=", 17)) { +#ifdef __APPLE__ + if (supress_ld_env && 0 == strncmp (environ[i], "DYLD_FALLBACK_LIBRARY_PATH", 26)) { + continue; + } +#else + if (supress_ld_env && 0 == strncmp (environ[i], "LD_LIBRARY_PATH", 15)) { continue; } #endif - envp[i] = strdup(environ[i]); - envp = (char **) realloc(envp, (i+2) * sizeof(char*)); + envp[j++] = strdup(environ[i]); + envp = (char **) realloc(envp, (j + 1) * sizeof(char*)); } - envp[i] = 0; + envp[j] = 0; } void