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

chromatic at svn.parrot.org chromatic at svn.parrot.org
Tue Oct 27 18:15:15 UTC 2009


Author: chromatic
Date: Tue Oct 27 18:15:14 2009
New Revision: 42137
URL: https://trac.parrot.org/parrot/changeset/42137

Log:
[PMC] Fixed some dodgy uses of potentially-uninitialized memory in
set_integer_native() and set_pointer_keyed_int() of CallSignatureReturns,
identified by Coveity CID #435.

Modified:
   trunk/src/pmc/callsignaturereturns.pmc

Modified: trunk/src/pmc/callsignaturereturns.pmc
==============================================================================
--- trunk/src/pmc/callsignaturereturns.pmc	Tue Oct 27 18:15:11 2009	(r42136)
+++ trunk/src/pmc/callsignaturereturns.pmc	Tue Oct 27 18:15:14 2009	(r42137)
@@ -13,7 +13,7 @@
 
 =head1 SYNOPSIS
 
-  # VTABLEs are too tight to implement something more beatyful
+  # VTABLEs are too tight to implement something more beautiful
 
   # Create signature
   rets = new CallSignatureReturns
@@ -142,9 +142,7 @@
                 cur          &= ~0xfff;
             }
 
-            values = values
-                   ? mem_realloc_n_typed(values, cur, void *)
-                   : mem_allocate_n_typed(cur, void *);
+            mem_realloc_n_typed(values, cur, void *);
 
             SET_ATTR_values(INTERP, SELF, values);
             SET_ATTR_size(INTERP, SELF, size);
@@ -189,10 +187,16 @@
         GET_ATTR_values(INTERP, SELF, values);
         GET_ATTR_size(INTERP,   SELF, size);
 
-        if (!values && key < 8) {
-            values = allocate_initial_values(INTERP, SELF);
-            SET_ATTR_values(INTERP, SELF, values);
-            SET_ATTR_size(INTERP, SELF, key + 1);
+        if (!values) {
+            if (key < 8) {
+                values = allocate_initial_values(INTERP, SELF);
+                SET_ATTR_values(INTERP, SELF, values);
+                SET_ATTR_size(INTERP, SELF, key + 1);
+            }
+            else {
+                STATICSELF.set_integer_native(key + 1);
+                GET_ATTR_values(INTERP, SELF, values);
+            }
         }
         else if (key >= size)
             STATICSELF.set_integer_native(key + 1);


More information about the parrot-commits mailing list