Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
compat/setenv: do not free what we fed putenv(3).
author
Junio C Hamano
<junkio@cox.net>
Sun, 4 Dec 2005 22:41:35 +0000
(14:41 -0800)
committer
Junio C Hamano
<junkio@cox.net>
Sun, 4 Dec 2005 22:41:35 +0000
(14:41 -0800)
Signed-off-by: Junio C Hamano <junkio@cox.net>
compat/setenv.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
4c353e8
)
diff --git
a/compat/setenv.c
b/compat/setenv.c
index 94acd2da9e2e95f9f9a72061d9575de6079dcaec..b7d76785980b81a6f1057d678d34a732f45ca4cd 100644
(file)
--- a/
compat/setenv.c
+++ b/
compat/setenv.c
@@
-16,7
+16,7
@@
int gitsetenv(const char *name, const char *value, int replace)
namelen = strlen(name);
valuelen = strlen(value);
namelen = strlen(name);
valuelen = strlen(value);
- envstr = malloc((namelen + valuelen + 2)
* sizeof(char)
);
+ envstr = malloc((namelen + valuelen + 2));
if (!envstr) return -1;
memcpy(envstr, name, namelen);
if (!envstr) return -1;
memcpy(envstr, name, namelen);
@@
-25,7
+25,11
@@
int gitsetenv(const char *name, const char *value, int replace)
envstr[namelen + valuelen + 1] = 0;
out = putenv(envstr);
envstr[namelen + valuelen + 1] = 0;
out = putenv(envstr);
+ /* putenv(3) makes the argument string part of the environment,
+ * and changing that string modifies the environment --- which
+ * means we do not own that storage anymore. Do not free
+ * envstr.
+ */
- free(envstr);
return out;
}
return out;
}