[前][次][番号順一覧][スレッド一覧]

ruby-changes:59984

From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Mon, 10 Feb 2020 12:22:34 +0900 (JST)
Subject: [ruby-changes:59984] f83781c8c1 (master): rb_enc_str_asciionly_p expects T_STRING

https://git.ruby-lang.org/ruby.git/commit/?id=f83781c8c1

From f83781c8c109b7f0b8cd6604d8fed6b8c13b8fd3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?=
 <shyouhei@r...>
Date: Mon, 10 Feb 2020 12:10:51 +0900
Subject: rb_enc_str_asciionly_p expects T_STRING

This `str2` variable can be non-string (regexp etc.) but the previous
code passed it directly to rb_enc_str_asciionly_p(), which expects its
argument be a string.  Let's enforce that constraint.

diff --git a/encoding.c b/encoding.c
index ca98b8e..f2e67ff 100644
--- a/encoding.c
+++ b/encoding.c
@@ -919,7 +919,7 @@ enc_compatible_latter(VALUE str1, VALUE str2, int idx1, int idx2) https://github.com/ruby/ruby/blob/trunk/encoding.c#L919
     if (isstr2 && RSTRING_LEN(str2) == 0)
 	return enc1;
     isstr1 = RB_TYPE_P(str1, T_STRING);
-    if (isstr1 && RSTRING_LEN(str1) == 0)
+    if (isstr1 && isstr2 && RSTRING_LEN(str1) == 0)
 	return (rb_enc_asciicompat(enc1) && rb_enc_str_asciionly_p(str2)) ? enc1 : enc2;
     if (!rb_enc_asciicompat(enc1) || !rb_enc_asciicompat(enc2)) {
 	return 0;
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]