mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
compile.c: check size
* compile.c (compile_data_alloc): check allocation size and integer overflow. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46960 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
39fd13bc5c
commit
61fd977798
1 changed files with 4 additions and 4 deletions
|
@ -595,13 +595,13 @@ compile_data_alloc(rb_iseq_t *iseq, size_t size)
|
|||
struct iseq_compile_data_storage *storage =
|
||||
iseq->compile_data->storage_current;
|
||||
|
||||
if (size >= INT_MAX) rb_memerror();
|
||||
if (storage->pos + size > storage->size) {
|
||||
unsigned long alloc_size = storage->size * 2;
|
||||
unsigned int alloc_size = storage->size;
|
||||
|
||||
retry:
|
||||
if (alloc_size < size) {
|
||||
while (alloc_size < size) {
|
||||
if (alloc_size >= INT_MAX / 2) rb_memerror();
|
||||
alloc_size *= 2;
|
||||
goto retry;
|
||||
}
|
||||
storage->next = (void *)ALLOC_N(char, alloc_size +
|
||||
SIZEOF_ISEQ_COMPILE_DATA_STORAGE);
|
||||
|
|
Loading…
Reference in a new issue