diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-09-13 08:12:54 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-09-13 08:12:54 +0000 |
commit | 8a6478763213ee4f377fbb3be1c6117a50f618dc (patch) | |
tree | a686204b200573b84a0379263861069a216ee8c6 /string.c | |
parent | be3baa4380dcc452299af0a9d26e08e3df56110d (diff) |
string.c: fix integer overflow
* string.c (rb_str_change_terminator_length): fix integer overflow
in the case growing the terminator length and the string length
is around LONG_MAX.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56149 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r-- | string.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -2054,7 +2054,8 @@ rb_str_change_terminator_length(VALUE str, const int oldtermlen, const int terml long capa = str_capacity(str, oldtermlen); long len = RSTRING_LEN(str); - if (capa < len + termlen - oldtermlen) { + assert(capa >= len); + if (capa - len < termlen - oldtermlen) { rb_check_lockedtmp(str); str_make_independent_expand(str, len, 0L, termlen); } |