diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-05-26 08:25:44 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-05-26 08:25:44 +0000 |
commit | e9dff3bfc66cdc0aeec1153066434d2a2502e933 (patch) | |
tree | d5126b86f6609d15d76fa601ee2ad1a849c5fc39 | |
parent | 1e426040c122aba11cb59f87ab4725acf8d8ec41 (diff) | |
download | ruby-e9dff3bfc66cdc0aeec1153066434d2a2502e933.tar.gz ruby-e9dff3bfc66cdc0aeec1153066434d2a2502e933.tar.xz ruby-e9dff3bfc66cdc0aeec1153066434d2a2502e933.zip |
* file.c (file_expand_path): add more space for '/'.
* file.c (file_expand_path): should reset address of p after calling
rb_str_resize(). [ruby-dev:34800]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@16613 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | file.c | 7 |
2 files changed, 13 insertions, 1 deletions
@@ -1,3 +1,10 @@ +Mon May 26 17:23:49 2008 NAKAMURA Usaku <usa@ruby-lang.org> + + * file.c (file_expand_path): add more space for '/'. + + * file.c (file_expand_path): should reset address of p after calling + rb_str_resize(). [ruby-dev:34800] + Mon May 26 16:49:55 2008 Yukihiro Matsumoto <matz@ruby-lang.org> * misc/ruby-mode.el (ruby-mode): use run-hooks if run-mode-hook is @@ -2730,8 +2730,10 @@ file_expand_path(VALUE fname, VALUE dname, VALUE result) } if (p > buf && p[-1] == '/') --p; - else + else { + BUFCHECK(bdiff >= ++buflen); *p = '/'; + } p[1] = 0; root = skipprefix(buf); @@ -2864,6 +2866,7 @@ file_expand_path(VALUE fname, VALUE dname, VALUE result) #endif HANDLE h = FindFirstFile(b, &wfd); if (h != INVALID_HANDLE_VALUE) { + long bdiff; FindClose(h); p = strrdirsep(buf); len = strlen(wfd.cFileName); @@ -2875,7 +2878,9 @@ file_expand_path(VALUE fname, VALUE dname, VALUE result) #endif if (!p) p = buf; buflen = ++p - buf + len; + bdiff = p - buf; rb_str_resize(result, buflen); + p = RSTRING_PTR(result) + bdiff; memcpy(p, wfd.cFileName, len + 1); } } |