raster pushed a commit to branch master. http://git.enlightenment.org/core/enlightenment.git/commit/?id=d798b9ea83795dbccb485e575088b69080f6f4d7
commit d798b9ea83795dbccb485e575088b69080f6f4d7 Author: Carsten Haitzler (Rasterman) <[email protected]> Date: Tue Jun 4 07:06:30 2019 +0100 e_start - fix alternate ifdef path putenv memory issue we'd have corrupted env vars with the alloca code we had to store the env var, so always malloc it at all times. as we won't (likely) be calling env_set() multiple times for the same environment we won't be leaking, and at worst - not very much at all. @fix --- src/bin/e_start_main.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/bin/e_start_main.c b/src/bin/e_start_main.c index b4e4d9f58..18d4cebbd 100644 --- a/src/bin/e_start_main.c +++ b/src/bin/e_start_main.c @@ -75,10 +75,13 @@ env_set(const char *var, const char *val) char *buf; size_t size = strlen(var) + 1 + strlen(val) + 1; - buf = alloca(size); + // yes - this does leak. we know. intentional if we set the same + // env multiple times because we likely won't and alloca is wrong + // as we lose the env content on the stack. but becomes part of + // the environment so it has to stay around after putenv is called + buf = malloc(size); sprintf(buf, "%s=%s", var, val); - if (getenv(var)) putenv(buf); - else putenv(strdup(buf)); + putenv(buf); #endif } else --
