diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-05-26 09:24:56 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-05-26 09:24:56 +0000 |
commit | d56e15200b75c32f4b6f854deed6872df4ed7d5b (patch) | |
tree | a82eac1e3207651c4c5484f2935249d2f4f3598a | |
parent | bae65bdc339aa7b848ddffb2153e52db91a41769 (diff) |
* file.c (BUFCHECK): no resize if enough room.
* file.c (file_expand_path): use BUFCHECK.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@16615 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | file.c | 16 |
2 files changed, 14 insertions, 8 deletions
@@ -1,3 +1,9 @@ +Mon May 26 18:24:48 2008 Nobuyoshi Nakada <[email protected]> + + * file.c (BUFCHECK): no resize if enough room. + + * file.c (file_expand_path): use BUFCHECK. + Mon May 26 16:46:19 2008 NAKAMURA Usaku <[email protected]> * file.c (ntfs_tail): filename which starts with '.' is valid. @@ -2497,13 +2497,13 @@ 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_PTR(result);\ + p = buf + bdiff;\ + pend = buf + buflen;\ }\ - rb_str_resize(result, buflen);\ - buf = RSTRING(result)->ptr;\ - p = buf + bdiff;\ - pend = buf + buflen;\ } while (0) #define BUFINIT() (\ @@ -2789,8 +2789,8 @@ file_expand_path(fname, dname, result) } #endif if (!p) p = buf; - buflen = ++p - buf + len; - rb_str_resize(result, buflen); + ++p; + BUFCHECK(bdiff + len >= buflen); memcpy(p, wfd.cFileName, len + 1); } } |