* 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
This commit is contained in:
nobu 2008-05-26 09:24:56 +00:00
parent bae65bdc33
commit d56e15200b
2 changed files with 14 additions and 8 deletions

View file

@ -1,3 +1,9 @@
Mon May 26 18:24:48 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* file.c (BUFCHECK): no resize if enough room.
* file.c (file_expand_path): use BUFCHECK.
Mon May 26 16:46:19 2008 NAKAMURA Usaku <usa@ruby-lang.org>
* file.c (ntfs_tail): filename which starts with '.' is valid.

16
file.c
View file

@ -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);
}
}