From 97f264398d1f46164ee02df023c2b57fc6afbec7 Mon Sep 17 00:00:00 2001 From: "hyunghwan.chung" Date: Fri, 20 Sep 2019 09:27:24 +0000 Subject: [PATCH] changed moo_shallowcopy() to stop copying a process object or an object with trailers --- moo/lib/gc.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/moo/lib/gc.c b/moo/lib/gc.c index cc375de..86317dd 100644 --- a/moo/lib/gc.c +++ b/moo/lib/gc.c @@ -1120,9 +1120,15 @@ moo_oop_t moo_shallowcopy (moo_t* moo, moo_oop_t oop) moo_oop_t z; moo_oow_t total_bytes; - total_bytes = MOO_SIZEOF(moo_obj_t) + moo_getobjpayloadbytes(moo, oop); + if (MOO_OBJ_GET_FLAGS_TRAILER(oop) || MOO_OBJ_GET_FLAGS_PROC(oop)) + { +/* TOOD: should i disallow this or return without copying? */ + moo_seterrbfmt (moo, MOO_EPERM, "not allowed to copy process or object with trailer"); + return MOO_NULL; + } /* TODO: exclude trailer and hash space? exclde hash space at least? */ + total_bytes = MOO_SIZEOF(moo_obj_t) + moo_getobjpayloadbytes(moo, oop); moo_pushvolat (moo, &oop); z = (moo_oop_t)moo_allocbytes(moo, total_bytes);