summaryrefslogtreecommitdiff
path: root/ext/date
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2022-09-29 14:15:55 +0900
committergit <svn-admin@ruby-lang.org>2022-09-29 14:56:39 +0900
commitcb16dcb1849b3b971b34ef2405949a57e65b8a8a (patch)
treecc3562fcd2951d5edd3e852bfdbd22c06f5702a5 /ext/date
parent942066713b736c2554f25513ae7986f04e929820 (diff)
downloadruby-cb16dcb1849b3b971b34ef2405949a57e65b8a8a.tar.gz
[ruby/date] The shrunk words to be copied is limited
Th buffer size is small enough and no need to allocate dynamically. https://github.com/ruby/date/commit/f62bf0a01d
Diffstat (limited to 'ext/date')
-rw-r--r--ext/date/date_parse.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/ext/date/date_parse.c b/ext/date/date_parse.c
index 6155293bb9..7349c75d84 100644
--- a/ext/date/date_parse.c
+++ b/ext/date/date_parse.c
@@ -442,14 +442,14 @@ date_zone_to_diff(VALUE str)
{
const char *zn = s;
long sl = shrunk_size(s, l);
- VALUE vbuf = 0;
+ char shrunk_buff[MAX_WORD_LENGTH]; /* no terminator to be added */
const struct zone *z = 0;
if (sl <= 0) {
sl = l;
}
else if (sl <= MAX_WORD_LENGTH) {
- char *d = ALLOCV_N(char, vbuf, sl);
+ char *d = shrunk_buff;
sl = shrink_space(d, s, l);
zn = d;
}
@@ -457,7 +457,6 @@ date_zone_to_diff(VALUE str)
if (sl > 0 && sl <= MAX_WORD_LENGTH) {
z = zonetab(zn, (unsigned int)sl);
}
- ALLOCV_END(vbuf);
if (z) {
int d = z->offset;