зеркало из https://github.com/github/ruby.git
* 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
This commit is contained in:
Родитель
9fff5f0fab
Коммит
37531934e6
|
@ -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
|
||||
|
|
10
parse.y
10
parse.y
|
@ -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);
|
||||
|
|
19
string.c
19
string.c
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче