[ruby-dev:31780] "string"[/str/]=:not_string dumps core

From: Nobuyoshi Nakada <nobu@...>
Date: 2007-09-14 14:47:26 UTC
List: ruby-dev #31780
なかだです。

http://yowaken.dip.jp/tdiary/20070908.html#p05 の件のパッチです。
ENCODING_*マクロはT_STRING限定ということですよね。


Index: encoding.c
===================================================================
--- encoding.c	(revision 13443)
+++ encoding.c	(working copy)
@@ -83,4 +83,5 @@ void
 rb_enc_associate_index(VALUE obj, int idx)
 {
+    Check_Type(obj, T_STRING);
     if (idx < ENCODING_INLINE_MAX) {
 	ENCODING_SET(obj, idx);
@@ -118,6 +119,8 @@ int
 rb_enc_get_index(VALUE obj)
 {
-    int i = ENCODING_GET(obj);
+    int i;
 
+    Check_Type(obj, T_STRING);
+    i = ENCODING_GET(obj);
     if (i == ENCODING_INLINE_MAX) {
 	VALUE iv;
Index: string.c
===================================================================
--- string.c	(revision 13443)
+++ string.c	(working copy)
@@ -1997,4 +1997,5 @@ rb_str_subpat_set(VALUE str, VALUE re, i
     end = RMATCH(match)->END(nth);
     len = end - start;
+    StringValue(val);
     rb_enc_check(str, val);
     rb_str_splice_0(str, start, len, val);


-- 
--- 僕の前にBugはない。
--- 僕の後ろにBugはできる。
    中田 伸悦

In This Thread

Prev Next