From: Erik Faye-Lund Date: Wed, 14 Dec 2011 14:07:08 +0000 (+0100) Subject: compat/setenv.c: update errno when erroring out X-Git-Tag: v1.7.8.2~10^2~1 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=57590c72b4d3b02e32732c7d79514c0281d6c2b5;p=git.git compat/setenv.c: update errno when erroring out Previously, gitsetenv didn't update errno as it should when erroring out. Fix this. Signed-off-by: Erik Faye-Lund Signed-off-by: Junio C Hamano --- diff --git a/compat/setenv.c b/compat/setenv.c index 3a22ea7b7..89947b713 100644 --- a/compat/setenv.c +++ b/compat/setenv.c @@ -6,7 +6,10 @@ int gitsetenv(const char *name, const char *value, int replace) 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); @@ -16,7 +19,10 @@ int gitsetenv(const char *name, const char *value, int replace) 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] = '=';