summaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2017-01-06 16:22:24 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-01-08 03:30:08 (GMT)
commit029443070a4e5b0290a2d09f3707bc486d84a961 (patch)
tree264eb5e2d4ae1ade17fd27aa68be1cdcbd047816 /sha1_file.c
parent2eb7a0e5e439f4249cd758ca728d5f054fa540bd (diff)
downloadgit-029443070a4e5b0290a2d09f3707bc486d84a961.zip
git-029443070a4e5b0290a2d09f3707bc486d84a961.tar.gz
git-029443070a4e5b0290a2d09f3707bc486d84a961.tar.bz2
safe_create_leading_directories_const(): preserve errno
Some implementations of free() change errno (even thought they shouldn't): https://sourceware.org/bugzilla/show_bug.cgi?id=17924 So preserve the errno from safe_create_leading_directories() across the call to free(). Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Reviewed-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/sha1_file.c b/sha1_file.c
index 1173071..10395e7 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -166,10 +166,14 @@ enum scld_error safe_create_leading_directories(char *path)
enum scld_error safe_create_leading_directories_const(const char *path)
{
+ int save_errno;
/* path points to cache entries, so xstrdup before messing with it */
char *buf = xstrdup(path);
enum scld_error result = safe_create_leading_directories(buf);
+
+ save_errno = errno;
free(buf);
+ errno = save_errno;
return result;
}