ruby-changes:38854
From: nobu <ko1@a...>
Date: Wed, 17 Jun 2015 16:22:03 +0900 (JST)
Subject: [ruby-changes:38854] nobu:r50935 (trunk): util.c: fix off-by-one error
nobu 2015-06-17 16:21:41 +0900 (Wed, 17 Jun 2015) New Revision: 50935 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=50935 Log: 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. Modified files: trunk/util.c Index: util.c =================================================================== --- util.c (revision 50934) +++ util.c (revision 50935) @@ -94,6 +94,7 @@ ruby_scan_digits(const char *str, ssize_ https://github.com/ruby/ruby/blob/trunk/util.c#L94 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_ https://github.com/ruby/ruby/blob/trunk/util.c#L105 if (ret < x) *overflow = 1; } while (len < 0 || --len); - *retlen = (str-1) - start; + *retlen = str - start; return ret; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/