summaryrefslogtreecommitdiff
path: root/src/bin/e_start_main.c
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2019-06-04 07:06:30 +0100
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2019-06-04 07:06:30 +0100
commitd798b9ea83795dbccb485e575088b69080f6f4d7 (patch)
tree303e3f838381fb242e7979a9135c9657bec1e6f9 /src/bin/e_start_main.c
parent540db8bd413fb233a6b40042c2d773d0d34de76e (diff)
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
Diffstat (limited to 'src/bin/e_start_main.c')
-rw-r--r--src/bin/e_start_main.c9
1 files 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)
75 char *buf; 75 char *buf;
76 size_t size = strlen(var) + 1 + strlen(val) + 1; 76 size_t size = strlen(var) + 1 + strlen(val) + 1;
77 77
78 buf = alloca(size); 78 // yes - this does leak. we know. intentional if we set the same
79 // env multiple times because we likely won't and alloca is wrong
80 // as we lose the env content on the stack. but becomes part of
81 // the environment so it has to stay around after putenv is called
82 buf = malloc(size);
79 sprintf(buf, "%s=%s", var, val); 83 sprintf(buf, "%s=%s", var, val);
80 if (getenv(var)) putenv(buf); 84 putenv(buf);
81 else putenv(strdup(buf));
82#endif 85#endif
83 } 86 }
84 else 87 else