summaryrefslogtreecommitdiffstats
path: root/string.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-08-12 06:39:08 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-08-12 06:39:08 +0000
commitd05190e895c385f2438b0aa7e624345abdbb6f7b (patch)
tree85217e4c22764bbdf4755ceb08839f764ddeb2f8 /string.c
parentaffff5630ca336f4c97072e0238a1568b98e8f3a (diff)
downloadruby-d05190e895c385f2438b0aa7e624345abdbb6f7b.tar.gz
ruby-d05190e895c385f2438b0aa7e624345abdbb6f7b.tar.xz
ruby-d05190e895c385f2438b0aa7e624345abdbb6f7b.zip
* string.c (rb_str_intern): should check symbol table overflow.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@18519 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/string.c b/string.c
index e14f298cc..ba2c454df 100644
--- a/string.c
+++ b/string.c
@@ -5840,10 +5840,25 @@ VALUE
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;
}