summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-08 05:06:52 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2018-11-08 05:06:52 +0000
commit24fff7504595dcbc5466d209485b13074fb33a3d (patch)
tree7e833bfc999d8f79c3a575b762f02a40747cceac /util.c
parentf4a2170ec27ca623d127353d5b19212a35fe9d70 (diff)
avoid (size_t)--
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@65624 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'util.c')
-rw-r--r--util.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/util.c b/util.c
index 0e49e44..1d95da9 100644
--- a/util.c
+++ b/util.c
@@ -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';
}