From 224efac3404e0a41993dc420c8249e985c74d083 Mon Sep 17 00:00:00 2001 From: usa Date: Mon, 26 May 2008 08:25:44 +0000 Subject: * 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@16613 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- file.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'file.c') diff --git a/file.c b/file.c index d5f39c7979..86e51c871a 100644 --- a/file.c +++ b/file.c @@ -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); } } -- cgit v1.2.3