diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-10-15 07:57:40 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-10-15 07:57:40 +0000 |
commit | 37531934e6e39c4863db87134c04efa3d3d63f61 (patch) | |
tree | e8e81ac2e16f4d88b9bfd384f035dcde7c5026e2 | |
parent | 9fff5f0fabb50ab0d46034d6c1b9dcc4447a8a66 (diff) | |
download | ruby-37531934e6e39c4863db87134c04efa3d3d63f61.tar.gz |
* parse.y (rb_intern3): check symbol table overflow.
[ruby-core:26092]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25351 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | parse.y | 10 | ||||
-rw-r--r-- | string.c | 19 |
3 files changed, 17 insertions, 17 deletions
@@ -1,3 +1,8 @@ +Thu Oct 15 16:57:38 2009 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * parse.y (rb_intern3): check symbol table overflow. + [ruby-core:26092] + Thu Oct 15 15:14:15 2009 Nobuyoshi Nakada <nobu@ruby-lang.org> * io.c (io_encoding_set): get rid of parsing non-ascii string, and @@ -9498,6 +9498,16 @@ rb_intern3(const char *name, long len, rb_encoding *enc) 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); @@ -6510,25 +6510,10 @@ VALUE 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); } |