diff options
author | Michael Haggerty <mhagger@alum.mit.edu> | 2017-01-06 19:22:24 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-01-08 06:30:08 +0300 |
commit | 029443070a4e5b0290a2d09f3707bc486d84a961 (patch) | |
tree | 264eb5e2d4ae1ade17fd27aa68be1cdcbd047816 /sha1_file.c | |
parent | 2eb7a0e5e439f4249cd758ca728d5f054fa540bd (diff) |
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.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/sha1_file.c b/sha1_file.c index 1173071859..10395e7e4b 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; } |