aboutsummaryrefslogtreecommitdiffstats
path: root/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'util.c')
-rw-r--r--util.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/util.c b/util.c
index 89dec0d19b..95ac2b09b5 100644
--- a/util.c
+++ b/util.c
@@ -507,9 +507,10 @@ ruby_getcwd(void)
char *buf = xmalloc(size);
while (!getcwd(buf, size)) {
- if (errno != ERANGE) {
+ int e = errno;
+ if (e != ERANGE) {
xfree(buf);
- rb_sys_fail("getcwd");
+ rb_syserr_fail(e, "getcwd");
}
size *= 2;
buf = xrealloc(buf, size);
@@ -527,8 +528,9 @@ ruby_getcwd(void)
char *buf = xmalloc(PATH_MAX+1);
if (!getwd(buf)) {
+ int e = errno;
xfree(buf);
- rb_sys_fail("getwd");
+ rb_syserr_fail(e, "getwd");
}
#endif
return buf;