diff --git a/st.c b/st.c index ee3dbb125d..6a943b8ddd 100644 --- a/st.c +++ b/st.c @@ -2036,8 +2036,9 @@ int st_locale_insensitive_strncasecmp(const char *s1, const char *s2, size_t n) { char c1, c2; + int i; - while (n--) { + for (i = 0; i < n; i++) { c1 = *s1++; c2 = *s2++; if (c1 == '\0' || c2 == '\0') { diff --git a/util.c b/util.c index 0e49e4439d..1d95da98bb 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'; }