Repository navigation
string.c: do not limit String#to_f/Float() input to 80 bytes - #7847
yuyongyan29-dev wants to merge 1 commit into
Conversation
Input was copied into a fixed buffer of DBL_DIG*4+20 bytes; longer strings returned INFINITY, or lost the remaining fraction and exponent once a dot had been seen (mruby#7846). Copy into a NUL-terminated buffer sized from the input, falling back to mrb_malloc() when it does not fit on the stack.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
mrb_str_len_to_dbl()copied its input into a fixed 80-byte buffer. Longer numeric strings returnedInfinity(even negative ones), or lost the rest of the fraction and the exponent once a.had been seen.Copy into a NUL-terminated buffer sized from the input instead, using
mrb_malloc()when it does not fit on the stack. Short inputs, underscores, andFloat()error checks behave as before.Adds tests for long strings and for shared substrings in
String#to_fandKernel#Float.Fixes #7846
Summary by CodeRabbit