mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
suppress integer overflow warnings
* random.c: annotate rb_hash_start with NO_SANITIZE (seed.key.hash + h overflows and that seems intentional) * bignum.c: avoid (size_t)-- * cont.c: ditto * util.c: ditto * vm_insnhelper.c: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65688 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
803dcea481
commit
7f6691ae77
5 changed files with 21 additions and 13 deletions
7
bignum.c
7
bignum.c
|
@ -2587,10 +2587,9 @@ bigdivrem_single1(BDIGIT *qds, const BDIGIT *xds, size_t xn, BDIGIT x_higher_bdi
|
|||
size_t i;
|
||||
BDIGIT_DBL t2;
|
||||
t2 = x_higher_bdigit;
|
||||
i = xn;
|
||||
while (i--) {
|
||||
t2 = BIGUP(t2) + xds[i];
|
||||
qds[i] = (BDIGIT)(t2 / y);
|
||||
for (i = 0; i < xn; i++) {
|
||||
t2 = BIGUP(t2) + xds[xn - i - 1];
|
||||
qds[xn - i - 1] = (BDIGIT)(t2 / y);
|
||||
t2 %= y;
|
||||
}
|
||||
return (BDIGIT)t2;
|
||||
|
|
12
cont.c
12
cont.c
|
@ -1199,7 +1199,7 @@ rollback_ensure_stack(VALUE self,rb_ensure_list_t *current,rb_ensure_entry_t *ta
|
|||
{
|
||||
rb_ensure_list_t *p;
|
||||
rb_ensure_entry_t *entry;
|
||||
size_t i;
|
||||
size_t i, j;
|
||||
size_t cur_size;
|
||||
size_t target_size;
|
||||
size_t base_point;
|
||||
|
@ -1237,11 +1237,11 @@ rollback_ensure_stack(VALUE self,rb_ensure_list_t *current,rb_ensure_entry_t *ta
|
|||
cur_size--;
|
||||
}
|
||||
/* push ensure stack */
|
||||
while (i--) {
|
||||
func = (VALUE (*)(ANYARGS)) lookup_rollback_func(target[i].e_proc);
|
||||
if ((VALUE)func != Qundef) {
|
||||
(*func)(target[i].data2);
|
||||
}
|
||||
for (j = 0; j < i; j++) {
|
||||
func = (VALUE (*)(ANYARGS)) lookup_rollback_func(target[i - j - 1].e_proc);
|
||||
if ((VALUE)func != Qundef) {
|
||||
(*func)(target[i - j - 1].data2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
1
random.c
1
random.c
|
@ -1573,6 +1573,7 @@ init_seed(struct MT *mt)
|
|||
seed.u32[i] = genrand_int32(mt);
|
||||
}
|
||||
|
||||
NO_SANITIZE("unsigned-integer-overflow", extern st_index_t rb_hash_start(st_index_t h));
|
||||
st_index_t
|
||||
rb_hash_start(st_index_t h)
|
||||
{
|
||||
|
|
10
util.c
10
util.c
|
@ -54,8 +54,16 @@ ruby_scan_hex(const char *start, size_t len, size_t *retlen)
|
|||
register const char *s = start;
|
||||
register unsigned long retval = 0;
|
||||
const char *tmp;
|
||||
size_t i = 0;
|
||||
|
||||
while (len-- && *s && (tmp = strchr(hexdigit, *s))) {
|
||||
for (i = 0; i < len; i++) {
|
||||
if (! s[0]) {
|
||||
break;
|
||||
}
|
||||
tmp = strchr(hexdigit, *s);
|
||||
if (! tmp) {
|
||||
break;
|
||||
}
|
||||
retval <<= 4;
|
||||
retval |= (tmp - hexdigit) & 15;
|
||||
s++;
|
||||
|
|
|
@ -3211,7 +3211,7 @@ vm_opt_newarray_max(rb_num_t num, const VALUE *ptr)
|
|||
else {
|
||||
struct cmp_opt_data cmp_opt = { 0, 0 };
|
||||
VALUE result = *ptr;
|
||||
rb_num_t i = num - 1;
|
||||
rb_snum_t i = num - 1;
|
||||
while (i-- > 0) {
|
||||
const VALUE v = *++ptr;
|
||||
if (OPTIMIZED_CMP(v, result, cmp_opt) > 0) {
|
||||
|
@ -3237,7 +3237,7 @@ vm_opt_newarray_min(rb_num_t num, const VALUE *ptr)
|
|||
else {
|
||||
struct cmp_opt_data cmp_opt = { 0, 0 };
|
||||
VALUE result = *ptr;
|
||||
rb_num_t i = num - 1;
|
||||
rb_snum_t i = num - 1;
|
||||
while (i-- > 0) {
|
||||
const VALUE v = *++ptr;
|
||||
if (OPTIMIZED_CMP(v, result, cmp_opt) < 0) {
|
||||
|
|
Loading…
Add table
Reference in a new issue