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

ruby-changes:7001

From: matz <ko1@a...>
Date: Tue, 12 Aug 2008 15:42:09 +0900 (JST)
Subject: [ruby-changes:7001] Ruby:r18519 (trunk): * string.c (rb_str_intern): should check symbol table overflow.

matz	2008-08-12 15:39:08 +0900 (Tue, 12 Aug 2008)

  New Revision: 18519

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=18519

  Log:
    * string.c (rb_str_intern): should check symbol table overflow.

  Modified files:
    trunk/ChangeLog
    trunk/string.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 18518)
+++ ChangeLog	(revision 18519)
@@ -1,3 +1,7 @@
+Tue Aug 12 15:37:40 2008  Yukihiro Matsumoto  <matz@r...>
+
+	* string.c (rb_str_intern): should check symbol table overflow.
+
 Tue Aug 12 15:31:04 2008  Minero Aoki  <aamine@l...>
 
 	* lib/net/http.rb (send_request_with_body): Content-Length should
Index: string.c
===================================================================
--- string.c	(revision 18518)
+++ string.c	(revision 18519)
@@ -5840,10 +5840,25 @@
 rb_str_intern(VALUE s)
 {
     VALUE str = RB_GC_GUARD(s);
-    ID id;
+    VALUE sym;
+    ID id, id2;
 
     id = rb_intern_str(str);
-    return ID2SYM(id);
+    sym = ID2SYM(id);
+    id2 = SYM2ID(sym);
+    if (id != id2) {
+	char *name = rb_id2name(id2);
+
+	if (name) {
+	    rb_raise(rb_eRuntimeError, "symbol table overflow (%s given for %s)",
+		     name, RSTRING_PTR(str));
+	}
+	else {
+	    rb_raise(rb_eRuntimeError, "symbol table overflow (symbol %s)",
+		     RSTRING_PTR(str));
+	}
+    }
+    return sym;
 }
 
 

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

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