1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
akr 2010-02-03 11:08:44 +00:00
parent 44b5a74a9a
commit 688ca71c13
2 changed files with 6 additions and 1 deletions

View file

@ -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> Wed Feb 3 13:15:24 2010 NARUSE, Yui <naruse@ruby-lang.org>
* thread_pthread.c: DragonFlyBSD is also the same as FreeBSD * thread_pthread.c: DragonFlyBSD is also the same as FreeBSD

3
file.c
View file

@ -3097,7 +3097,8 @@ realpath_rec(long *prefixlenp, VALUE *resolvedp, char *unresolved, VALUE loopche
else if (testnamelen == 2 && testname[0] == '.' && testname[1] == '.') { else if (testnamelen == 2 && testname[0] == '.' && testname[1] == '.') {
if (*prefixlenp < RSTRING_LEN(*resolvedp)) { if (*prefixlenp < RSTRING_LEN(*resolvedp)) {
char *resolved_names = RSTRING_PTR(*resolvedp) + *prefixlenp; 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); rb_str_set_len(*resolvedp, *prefixlenp + len);
} }
} }