Skip to content

Commit

Permalink
mrb_str_len_to_inum(): fixed a bug with underscores in digits; fix #3049
Browse files Browse the repository at this point in the history
  • Loading branch information
matz committed Dec 16, 2015
1 parent 80c1c60 commit d18c55f
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions src/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -2145,29 +2145,24 @@ mrb_str_len_to_inum(mrb_state *mrb, const char *str, size_t len, int base, int b
}
}
}
c = *p;
if (badcheck && c == '\0') {
goto bad;
}
c = conv_digit(c);
if (c < 0 || c >= base) {
if (p == pend) {
if (badcheck) goto bad;
return mrb_fixnum_value(0);
}

for ( ;p<pend;p++) {
if (*p == '_') {
if (p+1<pend && p[1] == '_') {
p++;
if (p==pend) {
if (badcheck) goto bad;
continue;
}
p++;
if (badcheck && p<pend)
goto bad;
if (*p == '_') {
if (badcheck) goto bad;
break;
}
}
if (badcheck && *p == '\0') {
goto nullbyte;
break;
}
c = conv_digit(*p);
if (c < 0 || c >= base) {
Expand Down

0 comments on commit d18c55f

Please sign in to comment.