summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-24 19:25:45 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-24 19:25:45 +0000
commitc94a89a739f32e9fcf64e2170b973717242090e3 (patch)
tree65d9f7e16e5ca9d4dcbcb9d983dfdfa047dd4299 /parse.y
parentedb8eee2365b8a1bdbaf72a50cdc4d8adf24c495 (diff)
* parse.y (rb_id2str): fill klass of returned string as rb_cString.
some strings are allocated before rb_cString is created. This prevents a "called on terminated object" error by ObjectSpace.each_object(Module) {|m| p m.name }. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14631 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y16
1 files changed, 12 insertions, 4 deletions
diff --git a/parse.y b/parse.y
index 3427a3c1ec..0a1f1acaaa 100644
--- a/parse.y
+++ b/parse.y
@@ -9039,8 +9039,12 @@ rb_id2str(ID id)
}
}
- if (st_lookup(global_symbols.id_str, id, &data))
- return (VALUE)data;
+ if (st_lookup(global_symbols.id_str, id, &data)) {
+ VALUE str = (VALUE)data;
+ if (RBASIC(str)->klass == 0)
+ RBASIC(str)->klass = rb_cString;
+ return str;
+ }
if (is_attrset_id(id)) {
ID id2 = (id & ~ID_SCOPE_MASK) | ID_LOCAL;
@@ -9053,8 +9057,12 @@ rb_id2str(ID id)
str = rb_str_dup(str);
rb_str_cat(str, "=", 1);
rb_intern_str(str);
- if (st_lookup(global_symbols.id_str, id, &data))
- return (VALUE)data;
+ if (st_lookup(global_symbols.id_str, id, &data)) {
+ VALUE str = (VALUE)data;
+ if (RBASIC(str)->klass == 0)
+ RBASIC(str)->klass = rb_cString;
+ return str;
+ }
}
return 0;
}