diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-06-17 07:21:41 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-06-17 07:21:41 +0000 |
commit | e521b916eca6b149252db69ff914223cfba54d50 (patch) | |
tree | 773a8fde06308879f753a87d339aed2e0bb1ec0c /util.c | |
parent | aabe6b46a810c012c13272f99800097bf08e0db3 (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.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -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; } |