[svn:parrot] r39197 - trunk/src/ops

NotFound at svn.parrot.org NotFound at svn.parrot.org
Wed May 27 17:48:19 UTC 2009


Author: NotFound
Date: Wed May 27 17:48:18 2009
New Revision: 39197
URL: https://trac.parrot.org/parrot/changeset/39197

Log:
[cage] cleaner fail when dest of the copy opcode is null, TT #714

Modified:
   trunk/src/ops/set.ops

Modified: trunk/src/ops/set.ops
==============================================================================
--- trunk/src/ops/set.ops	Wed May 27 15:37:40 2009	(r39196)
+++ trunk/src/ops/set.ops	Wed May 27 17:48:18 2009	(r39197)
@@ -490,33 +490,40 @@
 =cut
 
 inline op copy(inout PMC, invar PMC) :base_mem {
-  PMC   * const clone = VTABLE_clone(interp, $2);
-
-  /* Preserve the metadata on the destination. */
-  PMC   * const meta  = VTABLE_getprops(interp, $1);
-
-  /* avoid leaks and unreachable memory by destroying the destination PMC */
-  if (PObj_active_destroy_TEST($1))
-      VTABLE_destroy(interp, $1);
-
-  /* the source PMC knows how to clone itself, but we must reuse the
-   destination header */
-  memmove($1, clone, sizeof (PMC));
-
-  /* don't let the clone's destruction destroy the destination's data */
-  PObj_active_destroy_CLEAR(clone);
-  if (PObj_is_PMC_EXT_TEST(clone))
-    clone->pmc_ext = NULL;
-
-  /* Restore metadata. */
-  if (!PMC_IS_NULL(meta)) {
-      PMC * const iter = VTABLE_get_iter(interp, meta);
-      while (VTABLE_get_bool(interp, iter)) {
-          STRING * const key = VTABLE_shift_string(interp, iter);
-          PMC * const value  = VTABLE_get_pmc_keyed_str(interp, meta, key);
-          VTABLE_setprop(interp, $1, key, value);
-      }
-  }
+    if (PMC_IS_NULL($1)) {
+        opcode_t *dest = expr NEXT();
+        opcode_t *handler = Parrot_ex_throw_from_op_args(interp, dest,
+                EXCEPTION_NULL_REG_ACCESS, "Null PMC in clone");
+        goto ADDRESS(handler);
+    }
+    else {
+        PMC   * const clone = VTABLE_clone(interp, $2);
+        /* Preserve the metadata on the destination. */
+        PMC   * const meta  = VTABLE_getprops(interp, $1);
+
+        /* avoid leaks and unreachable memory by destroying the destination PMC */
+        if (PObj_active_destroy_TEST($1))
+            VTABLE_destroy(interp, $1);
+
+        /* the source PMC knows how to clone itself, but we must reuse the
+         * destination header */
+        memmove($1, clone, sizeof (PMC));
+
+        /* don't let the clone's destruction destroy the destination's data */
+        PObj_active_destroy_CLEAR(clone);
+        if (PObj_is_PMC_EXT_TEST(clone))
+            clone->pmc_ext = NULL;
+
+        /* Restore metadata. */
+        if (!PMC_IS_NULL(meta)) {
+            PMC * const iter = VTABLE_get_iter(interp, meta);
+            while (VTABLE_get_bool(interp, iter)) {
+                STRING * const key = VTABLE_shift_string(interp, iter);
+                PMC * const value  = VTABLE_get_pmc_keyed_str(interp, meta, key);
+                VTABLE_setprop(interp, $1, key, value);
+            }
+        }
+    }
 }
 
 =back


More information about the parrot-commits mailing list