aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/sys/unix
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2010-06-07 16:42:40 +0200
committerBjörn Gustavsson <[email protected]>2010-06-10 10:44:52 +0200
commit65ccc309a0225863913d991f56f17e2aa4f85266 (patch)
tree854ef04106740e83f0c20f1ea9ae3e30ef0a5648 /erts/emulator/sys/unix
parent6925a0da3cf0fd299e5e468fd95c4d0a697b86ae (diff)
downloadotp-65ccc309a0225863913d991f56f17e2aa4f85266.tar.gz
otp-65ccc309a0225863913d991f56f17e2aa4f85266.tar.bz2
otp-65ccc309a0225863913d991f56f17e2aa4f85266.zip
fix open_port with many unset env vars
The erlang:open_port spawn and spawn_executable directives can include an {env, Env} directive to set up environment variables for the spawned process. Variables can be unset with {"NameOfVariable",false}. A bug in ert/emulator/sys/unix/sys.c could cause unset variables to not be unset. This would typically happen if there where more variables to be unset than there where already set variables in the destination evironment. Fix this problem for unix and add a new regression test for it to the port test suite. Windows does not seem to have the same problem.
Diffstat (limited to 'erts/emulator/sys/unix')
-rw-r--r--erts/emulator/sys/unix/sys.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/erts/emulator/sys/unix/sys.c b/erts/emulator/sys/unix/sys.c
index 151fa06e8e..737ffd9f94 100644
--- a/erts/emulator/sys/unix/sys.c
+++ b/erts/emulator/sys/unix/sys.c
@@ -1328,10 +1328,18 @@ static char **build_unix_environment(char *block)
}
}
- for (j = 0; j < i; j++) {
+ for (j = 0; j < i; ) {
size_t last = strlen(cpp[j])-1;
if (cpp[j][last] == '=' && strchr(cpp[j], '=') == cpp[j]+last) {
cpp[j] = cpp[--len];
+ if (len < i) {
+ i--;
+ } else {
+ j++;
+ }
+ }
+ else {
+ j++;
}
}