[svn:parrot] r39368 - trunk/src/pmc
NotFound at svn.parrot.org
NotFound at svn.parrot.org
Wed Jun 3 14:56:34 UTC 2009
Author: NotFound
Date: Wed Jun 3 14:56:33 2009
New Revision: 39368
URL: https://trac.parrot.org/parrot/changeset/39368
Log:
[pmc] Sub self assignment protection
Modified:
trunk/src/pmc/sub.pmc
Modified: trunk/src/pmc/sub.pmc
==============================================================================
--- trunk/src/pmc/sub.pmc Wed Jun 3 13:45:37 2009 (r39367)
+++ trunk/src/pmc/sub.pmc Wed Jun 3 14:56:33 2009 (r39368)
@@ -440,20 +440,21 @@
if (other->vtable->base_type == SELF->vtable->base_type) {
Parrot_sub *my_sub;
Parrot_sub *other_sub;
+ PMC_get_sub(INTERP, SELF, my_sub);
+ PMC_get_sub(INTERP, other, other_sub);
+ /* Increase reference count of destination before
+ * freeing the one in self, to avoid problems in
+ * case of self assignment */
+ if (other_sub->ctx)
+ Parrot_context_ref(interp, other_sub->ctx);
/* 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);
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)
my_sub->name = Parrot_str_copy(INTERP, my_sub->name);
More information about the parrot-commits
mailing list