From: Michael Haggerty Date: Fri, 06 Jan 2017 16:22:24 GMT Subject: [PATCH v4 04/23] safe_create_leading_directories_const(): preserve errno Message-ID: <964bc414e7e96642aacb248e06912befab2724cc.1483719289.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