Permalink
Browse files

[PMC] Fixed a potential memory leak when resizing a FixedIntegerArray.

Added the use of temporary_pmc_new/temporary_pmc_free for a genuine temporary
PMC.  We'll see how this works.

git-svn-id: https://svn.parrot.org/parrot/trunk@32466 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
1 parent b10584a commit 4e871730d733848e00354a51a898daaca2dc4b8e @chromatic chromatic committed Nov 9, 2008
Showing with 3 additions and 2 deletions.
  1. +3 −2 src/pmc/fixedintegerarray.pmc
@@ -400,7 +400,7 @@ Resizes the array to C<size> elements.
"FixedIntegerArray: Can't resize!");
PMC_int_val(SELF) = size;
- PMC_data(SELF) = mem_sys_allocate_zeroed(size * sizeof (INTVAL));
+ mem_realloc_n_typed(PMC_data(SELF), size, INTVAL);
PObj_active_destroy_SET(SELF);
}
@@ -481,9 +481,10 @@ Sets the Parrot string value of the element at index C<key> to C<value>.
VTABLE void set_string_keyed_int(INTVAL key, STRING *value) {
INTVAL tempInt;
- PMC * const tempPMC = pmc_new(INTERP, enum_class_Integer);
+ PMC * const tempPMC = temporary_pmc_new(INTERP, enum_class_Integer);
VTABLE_set_string_native(INTERP, tempPMC, value);
tempInt = VTABLE_get_integer(INTERP, tempPMC);
+ temporary_pmc_free(interp, tempPMC);
SELF.set_integer_keyed_int(key, tempInt);
}

0 comments on commit 4e87173

Please sign in to comment.