[svn:parrot] r41149 - in trunk: src/pmc t/pmc

dukeleto at svn.parrot.org dukeleto at svn.parrot.org
Tue Sep 8 02:11:23 UTC 2009


Author: dukeleto
Date: Tue Sep  8 02:11:22 2009
New Revision: 41149
URL: https://trac.parrot.org/parrot/changeset/41149

Log:
[TT #991] Throw an exception when the creation of a negative length FixedPMCArray is attempted and prevent core dump

Modified:
   trunk/src/pmc/fixedpmcarray.pmc
   trunk/t/pmc/fixedpmcarray.t

Modified: trunk/src/pmc/fixedpmcarray.pmc
==============================================================================
--- trunk/src/pmc/fixedpmcarray.pmc	Tue Sep  8 01:33:19 2009	(r41148)
+++ trunk/src/pmc/fixedpmcarray.pmc	Tue Sep  8 02:11:22 2009	(r41149)
@@ -366,6 +366,10 @@
         if (!size)
             return;
 
+        if (size < 0)
+            Parrot_ex_throw_from_c_args(INTERP, NULL, EXCEPTION_OUT_OF_BOUNDS,
+                    _("FixedPMCArray: Cannot set array size to a negative number"));
+
         PMC_size(SELF) = size;
         data           = mem_allocate_n_typed(size, PMC *);
 

Modified: trunk/t/pmc/fixedpmcarray.t
==============================================================================
--- trunk/t/pmc/fixedpmcarray.t	Tue Sep  8 01:33:19 2009	(r41148)
+++ trunk/t/pmc/fixedpmcarray.t	Tue Sep  8 02:11:22 2009	(r41149)
@@ -19,15 +19,14 @@
 
 .sub main :main
     .include 'test_more.pir'
-    plan(75)
+    plan(76)
     test_setting_array_size()
     test_assign_from_another()
     test_assign_self()
     test_assign_non_array()
     test_resize_exception()
     test_truthiness()
-    # This test currently makes Parrot dump core
-    # test_tt991()
+    test_tt991()
     test_setting_first_elem()
     test_setting_second_elem()
     test_negative_index()
@@ -529,7 +528,7 @@
 .end
 
 .sub test_tt991
-    throws_like(<<'CODE',':s invalid size','invalid size')
+    throws_like(<<'CODE',':s FixedPMCArray\: Cannot set array size to a negative number','cannot create a negative length array')
         .sub main
             new $P0, ['FixedPMCArray']
             set $P0, -1


More information about the parrot-commits mailing list