string.c: empty non-embed case
* string.c (str_buf_cat): consider empty non-embed string case, not to loop infinitely. [ruby-core:70074] [Bug #11383] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51428 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
149dadf368
commit
6f65a0ebf2
@ -1,3 +1,8 @@
|
|||||||
|
Wed Jul 29 16:00:22 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* string.c (str_buf_cat): consider empty non-embed string case,
|
||||||
|
not to loop infinitely. [ruby-core:70074] [Bug #11383]
|
||||||
|
|
||||||
Wed Jul 29 15:25:19 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Wed Jul 29 15:25:19 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* vm_eval.c (send_internal): set method_missing_reason before
|
* vm_eval.c (send_internal): set method_missing_reason before
|
||||||
|
15
string.c
15
string.c
@ -2292,12 +2292,17 @@ str_buf_cat(VALUE str, const char *ptr, long len)
|
|||||||
}
|
}
|
||||||
total = olen + len;
|
total = olen + len;
|
||||||
if (capa <= total) {
|
if (capa <= total) {
|
||||||
while (total > capa) {
|
if (LIKELY(capa > 0)) {
|
||||||
if (capa > LONG_MAX / 2) {
|
while (total > capa) {
|
||||||
capa = (total + 4095) / 4096 * 4096;
|
if (capa > LONG_MAX / 2) {
|
||||||
break;
|
capa = (total + 4095) / 4096 * 4096;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
capa = 2 * capa;
|
||||||
}
|
}
|
||||||
capa = 2 * capa;
|
}
|
||||||
|
else {
|
||||||
|
capa = total;
|
||||||
}
|
}
|
||||||
RESIZE_CAPA_TERM(str, capa, termlen);
|
RESIZE_CAPA_TERM(str, capa, termlen);
|
||||||
sptr = RSTRING_PTR(str);
|
sptr = RSTRING_PTR(str);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user