summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 10dd3b2)
raw | patch | inline | side by side (parent: 10dd3b2)
author | Erik Faye-Lund <kusmabite@gmail.com> | |
Wed, 14 Dec 2011 14:07:08 +0000 (15:07 +0100) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 15 Dec 2011 03:30:41 +0000 (19:30 -0800) |
Previously, gitsetenv didn't update errno as it should when
erroring out. Fix this.
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
erroring out. Fix this.
Signed-off-by: Erik Faye-Lund <kusmabite@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
compat/setenv.c | patch | blob | history |
diff --git a/compat/setenv.c b/compat/setenv.c
index 3a22ea7b751efb768d72afa2f97fd963e10eec7e..89947b7134a7671c7f035e48bf8cd5f3ce4bc7c4 100644 (file)
--- a/compat/setenv.c
+++ b/compat/setenv.c
size_t namelen, valuelen;
char *envstr;
- if (!name || !value) return -1;
+ if (!name || !value) {
+ errno = EINVAL;
+ return -1;
+ }
if (!replace) {
char *oldval = NULL;
oldval = getenv(name);
namelen = strlen(name);
valuelen = strlen(value);
envstr = malloc((namelen + valuelen + 2));
- if (!envstr) return -1;
+ if (!envstr) {
+ errno = ENOMEM;
+ return -1;
+ }
memcpy(envstr, name, namelen);
envstr[namelen] = '=';