ruby-changes:13570
From: nobu <ko1@a...>
Date: Thu, 15 Oct 2009 16:58:21 +0900 (JST)
Subject: [ruby-changes:13570] Ruby:r25351 (trunk): * parse.y (rb_intern3): check symbol table overflow.
nobu 2009-10-15 16:57:40 +0900 (Thu, 15 Oct 2009) New Revision: 25351 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=25351 Log: * parse.y (rb_intern3): check symbol table overflow. [ruby-core:26092] Modified files: trunk/ChangeLog trunk/parse.y trunk/string.c Index: ChangeLog =================================================================== --- ChangeLog (revision 25350) +++ ChangeLog (revision 25351) @@ -1,3 +1,8 @@ +Thu Oct 15 16:57:38 2009 Nobuyoshi Nakada <nobu@r...> + + * parse.y (rb_intern3): check symbol table overflow. + [ruby-core:26092] + Thu Oct 15 15:14:15 2009 Nobuyoshi Nakada <nobu@r...> * io.c (io_encoding_set): get rid of parsing non-ascii string, and Index: string.c =================================================================== --- string.c (revision 25350) +++ string.c (revision 25351) @@ -6510,25 +6510,10 @@ rb_str_intern(VALUE s) { VALUE str = RB_GC_GUARD(s); - VALUE sym; - ID id, id2; + ID id; id = rb_intern_str(str); - sym = ID2SYM(id); - id2 = SYM2ID(sym); - if (id != id2) { - const 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; + return ID2SYM(id); } Index: parse.y =================================================================== --- parse.y (revision 25350) +++ parse.y (revision 25351) @@ -9498,6 +9498,16 @@ mbstr:; } new_id: + if (!(global_symbols.last_id << (ID_SCOPE_SHIFT+RUBY_SPECIAL_SHIFT))) { + if (len > 20) { + rb_raise(rb_eRuntimeError, "symbol table overflow (symbol %.20s...)", + name); + } + else { + rb_raise(rb_eRuntimeError, "symbol table overflow (symbol %.*s)", + (int)len, name); + } + } id |= ++global_symbols.last_id << ID_SCOPE_SHIFT; id_register: return register_symid(id, name, len, enc); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/