diff options
author | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-06-15 14:24:09 +0000 |
---|---|---|
committer | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-06-15 14:24:09 +0000 |
commit | 0bec319ab19d9db8ae390cd21c673d2f60792367 (patch) | |
tree | 843c7a1f68bc869b84a998cbc5230f487490c2d0 /file.c | |
parent | dc2d035f67ce73ce0e09314875674465e62c367e (diff) |
merge revision(s) 16618:
* file.c (BUFCHECK): wrong condition. [ruby-core:16921]
* file.c (file_expand_buf): shouldn't use buflen for length of string.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8_5@17333 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r-- | file.c | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -2520,8 +2520,12 @@ ntfs_tail(const char *path) #define BUFCHECK(cond) do {\ long bdiff = p - buf;\ - while (cond) {\ - buflen *= 2;\ + if (cond) {\ + do {buflen *= 2;} while (cond);\ + rb_str_resize(result, buflen);\ + buf = RSTRING(result)->ptr;\ + p = buf + bdiff;\ + pend = buf + buflen;\ }\ rb_str_resize(result, buflen);\ buf = RSTRING(result)->ptr;\ @@ -2762,7 +2766,6 @@ file_expand_path(fname, dname, result) p += s-b; } if (p == skiproot(buf) - 1) p++; - buflen = p - buf; #if USE_NTFS *p = '\0'; @@ -2811,13 +2814,14 @@ file_expand_path(fname, dname, result) buflen = ++p - buf + len; rb_str_resize(result, buflen); memcpy(p, wfd.cFileName, len + 1); + p += len; } } #endif if (tainted) OBJ_TAINT(result); - RSTRING(result)->len = buflen; - RSTRING(result)->ptr[buflen] = '\0'; + RSTRING(result)->len = p - buf; + RSTRING(result)->ptr[p - buf] = '\0'; return result; } |