Skip to content

Commit 34a0f41

Browse files
committed
merge revision(s) c1862cb: [Backport #20719]
[Bug #20719] `Float` argument must be ASCII compatible
1 parent 2b713dc commit 34a0f41

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

object.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3489,6 +3489,7 @@ rb_str_to_dbl_raise(VALUE str, int badcheck, int raise, int *error)
34893489
VALUE v = 0;
34903490

34913491
StringValue(str);
3492+
rb_must_asciicompat(str);
34923493
s = RSTRING_PTR(str);
34933494
len = RSTRING_LEN(str);
34943495
if (s) {

test/ruby/test_float.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,12 @@ def test_Float
850850
o = Object.new
851851
def o.to_f; inf = Float::INFINITY; inf/inf; end
852852
assert_predicate(Float(o), :nan?)
853+
854+
assert_raise(Encoding::CompatibilityError) {Float("0".encode("utf-16be"))}
855+
assert_raise(Encoding::CompatibilityError) {Float("0".encode("utf-16le"))}
856+
assert_raise(Encoding::CompatibilityError) {Float("0".encode("utf-32be"))}
857+
assert_raise(Encoding::CompatibilityError) {Float("0".encode("utf-32le"))}
858+
assert_raise(Encoding::CompatibilityError) {Float("0".encode("iso-2022-jp"))}
853859
end
854860

855861
def test_invalid_str

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
1212
#define RUBY_VERSION_TEENY 5
1313
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
14-
#define RUBY_PATCHLEVEL 103
14+
#define RUBY_PATCHLEVEL 104
1515

1616
#include "ruby/version.h"
1717
#include "ruby/internal/abi.h"

0 commit comments

Comments
 (0)