mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
util.c: fix off-by-one error
* util.c (ruby_scan_digits): fix the return length off-by-one error when the length is given and the last char is a digit. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50935 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
aabe6b46a8
commit
e521b916ec
1 changed files with 2 additions and 1 deletions
3
util.c
3
util.c
|
@ -94,6 +94,7 @@ ruby_scan_digits(const char *str, ssize_t len, int base, size_t *retlen, int *ov
|
|||
do {
|
||||
int d = ruby_digit36_to_number_table[(unsigned char)*str++];
|
||||
if (d == -1 || base <= d) {
|
||||
--str;
|
||||
break;
|
||||
}
|
||||
if (mul_overflow < ret)
|
||||
|
@ -104,7 +105,7 @@ ruby_scan_digits(const char *str, ssize_t len, int base, size_t *retlen, int *ov
|
|||
if (ret < x)
|
||||
*overflow = 1;
|
||||
} while (len < 0 || --len);
|
||||
*retlen = (str-1) - start;
|
||||
*retlen = str - start;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue