summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2001-09-03 18:25:58 +0000
committerJim Meyering <jim@meyering.net>2001-09-03 18:25:58 +0000
commitc9488ff0e1e7b1ace2121f5a0a01a9ca351b4dcc (patch)
treed1b2638f103d404e70064d986e1bc57d86868659 /lib
parent8df5a2474cfbad3c57b5c1ca60ec339f7b7898c4 (diff)
downloadcoreutils-c9488ff0e1e7b1ace2121f5a0a01a9ca351b4dcc.tar.xz
(xreadlink): Preserve errno around `free' during failure.
Diffstat (limited to 'lib')
-rw-r--r--lib/xreadlink.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/xreadlink.c b/lib/xreadlink.c
index 881b794f1..a01833381 100644
--- a/lib/xreadlink.c
+++ b/lib/xreadlink.c
@@ -58,7 +58,9 @@ xreadlink (char const *filename, size_t *link_length_arg)
link_length = readlink (filename, buffer, buf_size);
if (link_length < 0)
{
+ int saved_errno = errno;
free (buffer);
+ errno = saved_errno;
return NULL;
}
if (link_length < buf_size)