summaryrefslogtreecommitdiff
path: root/file.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-02-03 11:08:44 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-02-03 11:08:44 +0000
commit688ca71c13c46ef7df022845266eb4549b98f38c (patch)
tree87a65d27231c9a605f2417f81fdf2ae658d21615 /file.c
parent44b5a74a9ae22aa08f226b7f1d555fad928a8cf7 (diff)
* file.c (realpath_rec): rb_path_last_separator may return NULL.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26551 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r--file.c3
1 files changed, 2 insertions, 1 deletions
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);
}
}