summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--file.c3
2 files changed, 6 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 572046af74..81e0f5b5cc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Wed Feb 3 20:08:05 2010 Tanaka Akira <akr@fsij.org>
+
+ * file.c (realpath_rec): rb_path_last_separator may return NULL.
+
Wed Feb 3 13:15:24 2010 NARUSE, Yui <naruse@ruby-lang.org>
* thread_pthread.c: DragonFlyBSD is also the same as FreeBSD
diff --git a/file.c b/file.c
index ed8d27af17..e89a3cd864 100644
--- a/file.c
+++ b/file.c
@@ -3097,7 +3097,8 @@ realpath_rec(long *prefixlenp, VALUE *resolvedp, char *unresolved, VALUE loopche
else if (testnamelen == 2 && testname[0] == '.' && testname[1] == '.') {
if (*prefixlenp < RSTRING_LEN(*resolvedp)) {
char *resolved_names = RSTRING_PTR(*resolvedp) + *prefixlenp;
- long len = rb_path_last_separator(resolved_names) - resolved_names;
+ char *lastsep = rb_path_last_separator(resolved_names);
+ long len = lastsep ? lastsep - resolved_names : 0;
rb_str_set_len(*resolvedp, *prefixlenp + len);
}
}