summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-10-01 13:45:06 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-10-01 13:45:06 +0000
commit02914c8a16194cb8afd89dc93ba6eca2512d8e2c (patch)
treec323fa3391a2454ff0ba6c09152e4c4d5df05016 /gc.c
parentac7497416dd6cac1a8c8a5ab35010da5a09ccc25 (diff)
* gc.c (id2ref): valid id should not refer T_VALUE nor T_ICLASS.
[ruby-dev:31911] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@13587 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/gc.c b/gc.c
index 052df8f362..4298a8acf1 100644
--- a/gc.c
+++ b/gc.c
@@ -1922,6 +1922,7 @@ id2ref(obj, objid)
VALUE obj, objid;
{
unsigned long ptr, p0;
+ int type;
rb_secure(4);
p0 = ptr = NUM2ULONG(objid);
@@ -1938,7 +1939,8 @@ id2ref(obj, objid)
return ID2SYM(symid);
}
- if (!is_pointer_to_heap((void *)ptr)|| BUILTIN_TYPE(ptr) >= T_BLKTAG) {
+ if (!is_pointer_to_heap((void *)ptr)||
+ (type = BUILTIN_TYPE(ptr)) >= T_BLKTAG || type == T_ICLASS) {
rb_raise(rb_eRangeError, "0x%lx is not id value", p0);
}
if (BUILTIN_TYPE(ptr) == 0 || RBASIC(ptr)->klass == 0) {