diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-01-20 05:13:27 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-01-20 05:13:27 +0000 |
commit | 389c5843adf2c732b6a04560017544c63076f1b4 (patch) | |
tree | e458093752d98ac504af3a9c86991cfda90dfc93 /object.c | |
parent | b5d43b1db567fd2ffee4407e31b85cead490e7a4 (diff) |
merge revision(s) 63322: [Backport #14731]
object.c: fix exponent with underscore
* object.c (rb_cstr_to_dbl_raise): do not ignore exponent part
when the input string longer than internal buffer contains
underscore(s). [ruby-core:86836] [Bug #14731]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_5@66879 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'object.c')
-rw-r--r-- | object.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -3241,7 +3241,8 @@ rb_cstr_to_dbl(const char *p, int badcheck) if (*end) { char buf[DBL_DIG * 4 + 10]; char *n = buf; - char *e = buf + sizeof(buf) - 1; + char *const init_e = buf + DBL_DIG * 4; + char *e = init_e; char prev = 0; while (p < end && n < e) prev = *n++ = *p++; @@ -3254,6 +3255,9 @@ rb_cstr_to_dbl(const char *p, int badcheck) } } prev = *p++; + if (e == init_e && (*p == 'e' || *p == 'E')) { + e = buf + sizeof(buf) - 1; + } if (n < e) *n++ = prev; } *n = '\0'; |