summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-06-17 07:21:41 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-06-17 07:21:41 +0000
commite521b916eca6b149252db69ff914223cfba54d50 (patch)
tree773a8fde06308879f753a87d339aed2e0bb1ec0c /util.c
parentaabe6b46a810c012c13272f99800097bf08e0db3 (diff)
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
Diffstat (limited to 'util.c')
-rw-r--r--util.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/util.c b/util.c
index 0319fb5b49..aede3df62d 100644
--- a/util.c
+++ b/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;
}