diff options
author | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-11-08 06:22:57 +0000 |
---|---|---|
committer | shyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-11-08 06:22:57 +0000 |
commit | 7cc97cfe092c43d9729412fde2e1aa54746f2307 (patch) | |
tree | 1de7f2b3a89223fb969999bb1122736f9652494f /util.c | |
parent | c68d1c924cfde9c86652a13b9e76b8930c034142 (diff) |
avoid (size_t)-- (2nd try)
The decrements overflow and these variables remain ~0 when leaving the
while loops. They are not fatal by accident, but better replace with
ordinal for loops.
See also: https://travis-ci.org/ruby/ruby/jobs/452218871#L3246
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65630 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -35,8 +35,12 @@ ruby_scan_oct(const char *start, size_t len, size_t *retlen) { register const char *s = start; register unsigned long retval = 0; + size_t i; - while (len-- && *s >= '0' && *s <= '7') { + for (i = 0; i < len; i++) { + if ((s[0] < '0') || ('7' < s[0])) { + break; + } retval <<= 3; retval |= *s++ - '0'; } |