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>
This commit is contained in:

committed by
Junio C Hamano

parent
2eb7a0e5e4
commit
029443070a
@ -166,10 +166,14 @@ enum scld_error safe_create_leading_directories(char *path)
|
|||||||
|
|
||||||
enum scld_error safe_create_leading_directories_const(const 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 */
|
/* path points to cache entries, so xstrdup before messing with it */
|
||||||
char *buf = xstrdup(path);
|
char *buf = xstrdup(path);
|
||||||
enum scld_error result = safe_create_leading_directories(buf);
|
enum scld_error result = safe_create_leading_directories(buf);
|
||||||
|
|
||||||
|
save_errno = errno;
|
||||||
free(buf);
|
free(buf);
|
||||||
|
errno = save_errno;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user