summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-13 00:40:52 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-13 00:40:52 +0000
commit7f6691ae77546b42a4b182ca5ddbf5e2312c6a7b (patch)
tree7f1b465783cd3a61738aecc85c56e9fee834b106 /util.c
parent803dcea481ea20fc7dfc690e73ccb23646a5c4ab (diff)
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
Diffstat (limited to 'util.c')
-rw-r--r--util.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/util.c b/util.c
index 9835d7f..ea68110 100644
--- a/util.c
+++ b/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++;