ruby-changes:72988
From: Nobuyoshi <ko1@a...>
Date: Sat, 20 Aug 2022 10:06:54 +0900 (JST)
Subject: [ruby-changes:72988] 43e8d9a050 (master): Check if encoding capable object before check if ASCII compatible
https://git.ruby-lang.org/ruby.git/commit/?id=43e8d9a050 From 43e8d9a0509e1961c406fedb2c168a6ec2359fdc Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Fri, 19 Aug 2022 23:39:52 +0900 Subject: Check if encoding capable object before check if ASCII compatible --- string.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/string.c b/string.c index 6f211b2005..cd4a593856 100644 --- a/string.c +++ b/string.c @@ -2526,6 +2526,9 @@ void https://github.com/ruby/ruby/blob/trunk/string.c#L2526 rb_must_asciicompat(VALUE str) { rb_encoding *enc = rb_enc_get(str); + if (!enc) { + rb_raise(rb_eTypeError, "not encoding capable object"); + } if (!rb_enc_asciicompat(enc)) { rb_raise(rb_eEncCompatError, "ASCII incompatible encoding: %s", rb_enc_name(enc)); } -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/