summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-05-26 09:24:56 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-05-26 09:24:56 +0000
commitd56e15200b75c32f4b6f854deed6872df4ed7d5b (patch)
treea82eac1e3207651c4c5484f2935249d2f4f3598a
parentbae65bdc339aa7b848ddffb2153e52db91a41769 (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--ChangeLog6
-rw-r--r--file.c16
2 files changed, 14 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index 4aebf8bed2..daf0c847ff 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/file.c b/file.c
index 94e421fc82..cc9f030906 100644
--- a/file.c
+++ b/file.c
@@ -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);
}
}