From: Michael Haggerty Date: Sat, 31 Dec 2016 03:12:43 GMT Subject: [PATCH v3 03/23] safe_create_leading_directories_const(): preserve errno Message-ID: <2d685f4c5cbe17bf1abf2ef3fb2f03fd20a0c23d.1483153436.git.mhagger@alum.mit.edu> In-Reply-To: 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 --- sha1_file.c | 4 ++++ 1 file changed, 4 insertions(+) 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; } -- 2.9.3