diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2020-01-06 22:25:05 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2020-01-06 22:25:05 +0900 |
| commit | 59756aef149dd70d74146526c70679c47cab0811 (patch) | |
| tree | 180c0844bc480db59e19a99e8600dc9f8391d214 /src/string.c | |
| parent | 874797f36fe1ad459d9b678cddcd77c11afb76f1 (diff) | |
| download | mruby-59756aef149dd70d74146526c70679c47cab0811.tar.gz mruby-59756aef149dd70d74146526c70679c47cab0811.zip | |
Need to preserve the original input string in `mrb_str_len_to_dbl`.
Diffstat (limited to 'src/string.c')
| -rw-r--r-- | src/string.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/string.c b/src/string.c index 7b6a11a6f..93e4847d0 100644 --- a/src/string.c +++ b/src/string.c @@ -2492,16 +2492,15 @@ double mrb_str_len_to_dbl(mrb_state *mrb, const char *s, size_t len, mrb_bool badcheck) { char buf[DBL_DIG * 4 + 10]; - const char *p; - const char *pend = s + len; + const char *p = s; + const char *pend = p + len; char *end; char *n; char prev = 0; double d; - if (!s) return 0.0; - while (ISSPACE(*s)) s++; - p = s; + if (!p) return 0.0; + while (ISSPACE(*p)) p++; if (p[0] == '0' && (p[1] == 'x' || p[1] == 'X')) { mrb_value x; |
