aboutsummaryrefslogtreecommitdiffstats
path: root/iseq.h
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-07-17 16:54:59 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-07-17 16:54:59 +0000
commitca2d6be10fb8c09af2f833e6898ddcd3a86928d1 (patch)
treeec7d80fa70593a0efa838ff46fab3b1ed112e0b3 /iseq.h
parent083c5896caa16f713ed109b188b93ba1115e7fb4 (diff)
downloadruby-ca2d6be10fb8c09af2f833e6898ddcd3a86928d1.tar.gz
iseq.h: check range
* iseq.h (iseq_catch_table_bytes): check range and suppress a warning. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46854 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'iseq.h')
-rw-r--r--iseq.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/iseq.h b/iseq.h
index 4d95a7a135..9a225180df 100644
--- a/iseq.h
+++ b/iseq.h
@@ -76,8 +76,12 @@ PACKED_STRUCT_UNALIGNED(struct iseq_catch_table {
static inline int
iseq_catch_table_bytes(int n)
{
- return sizeof(struct iseq_catch_table) +
- (n - 1) * sizeof(struct iseq_catch_table_entry);
+ enum {
+ catch_table_entries_max = (INT_MAX - sizeof(struct iseq_catch_table)) / sizeof(struct iseq_catch_table_entry)
+ };
+ if (n > catch_table_entries_max) rb_fatal("too large iseq_catch_table - %d", n);
+ return (int)(sizeof(struct iseq_catch_table) +
+ (n - 1) * sizeof(struct iseq_catch_table_entry));
}
#define INITIAL_ISEQ_COMPILE_DATA_STORAGE_BUFF_SIZE (512)