Author: chromatic
Date: Sun Nov  9 00:12:24 2008
New Revision: 32466

Modified:
   trunk/src/pmc/fixedintegerarray.pmc

Log:
[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.

Modified: trunk/src/pmc/fixedintegerarray.pmc
==============================================================================
--- trunk/src/pmc/fixedintegerarray.pmc (original)
+++ trunk/src/pmc/fixedintegerarray.pmc Sun Nov  9 00:12:24 2008
@@ -400,7 +400,7 @@
                 "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 @@
 
     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);
     }
 

Reply via email to