[svn:parrot] r39343 - trunk/src/pmc

chromatic at svn.parrot.org chromatic at svn.parrot.org
Tue Jun 2 20:17:58 UTC 2009


Author: chromatic
Date: Tue Jun  2 20:17:57 2009
New Revision: 39343
URL: https://trac.parrot.org/parrot/changeset/39343

Log:
[PMC] Fixed context reference count updating in assign_pmc vtable (kudos to
NotFound for diagnosing the problem).

Modified:
   trunk/src/pmc/sub.pmc

Modified: trunk/src/pmc/sub.pmc
==============================================================================
--- trunk/src/pmc/sub.pmc	Tue Jun  2 20:06:11 2009	(r39342)
+++ trunk/src/pmc/sub.pmc	Tue Jun  2 20:17:57 2009	(r39343)
@@ -435,10 +435,18 @@
             Parrot_sub *my_sub;
             Parrot_sub *other_sub;
 
-            /* copy the sub struct */
+            /* get rid of this context, if attached */
             PMC_get_sub(INTERP, SELF, my_sub);
+            if (my_sub->ctx)
+                Parrot_free_context(INTERP, my_sub->ctx, 1);
+
+            /* copy the sub struct */
             PMC_get_sub(INTERP, other, other_sub);
-            memcpy(my_sub, other_sub, sizeof (Parrot_sub));
+            memmove(my_sub, other_sub, sizeof (Parrot_sub));
+
+            /* attach to the new context, if it exists */
+            if (my_sub->ctx)
+                Parrot_context_ref(interp, my_sub->ctx);
 
             /* copy the name so it's a different string in memory */
             if (my_sub->name)


More information about the parrot-commits mailing list