mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
c68d1c924c
commit
7cc97cfe09
2 changed files with 7 additions and 2 deletions
3
st.c
3
st.c
|
@ -2036,8 +2036,9 @@ int
|
|||
st_locale_insensitive_strncasecmp(const char *s1, const char *s2, size_t n)
|
||||
{
|
||||
char c1, c2;
|
||||
size_t i;
|
||||
|
||||
while (n--) {
|
||||
for (i = 0; i < n; i++) {
|
||||
c1 = *s1++;
|
||||
c2 = *s2++;
|
||||
if (c1 == '\0' || c2 == '\0') {
|
||||
|
|
6
util.c
6
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';
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue