diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2016-11-30 03:38:55 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2016-11-30 03:38:55 +0900 |
| commit | 630733f34698047e3b7b4e66cf929f626123b14e (patch) | |
| tree | 61d91874c18a47f81e90d403f5deb0b48f3a2314 /src | |
| parent | 27d166d4e2b09796408e2e9c2a493ddc4f6a3817 (diff) | |
| download | mruby-630733f34698047e3b7b4e66cf929f626123b14e.tar.gz mruby-630733f34698047e3b7b4e66cf929f626123b14e.zip | |
check ttype before object allocation; fix #3294
Diffstat (limited to 'src')
| -rw-r--r-- | src/gc.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -479,6 +479,17 @@ mrb_obj_alloc(mrb_state *mrb, enum mrb_vtype ttype, struct RClass *cls) static const RVALUE RVALUE_zero = { { { MRB_TT_FALSE } } }; mrb_gc *gc = &mrb->gc; + if (cls) { + enum mrb_vtype tt = MRB_INSTANCE_TT(cls); + if (tt != MRB_TT_FALSE && + ttype != MRB_TT_SCLASS && + ttype != MRB_TT_ICLASS && + ttype != MRB_TT_ENV && + ttype != tt) { + mrb_raisef(mrb, E_TYPE_ERROR, "allocation failure of %S", mrb_obj_value(cls)); + } + } + #ifdef MRB_GC_STRESS mrb_full_gc(mrb); #endif |
