[pypy-commit] pypy arm-backed-float: add some assertions about arguments to malloc operations

bivab noreply at buildbot.pypy.org
Fri Jun 10 12:59:29 CEST 2011


Author: David Schneider <david.schneider at picle.org>
Branch: arm-backed-float
Changeset: r44875:22e9b8d7d0eb
Date: 2011-06-10 12:59 +0200
http://bitbucket.org/pypy/pypy/changeset/22e9b8d7d0eb/

Log:	add some assertions about arguments to malloc operations

diff --git a/pypy/jit/backend/llsupport/gc.py b/pypy/jit/backend/llsupport/gc.py
--- a/pypy/jit/backend/llsupport/gc.py
+++ b/pypy/jit/backend/llsupport/gc.py
@@ -599,6 +599,7 @@
 
         # make a malloc function, with three arguments
         def malloc_basic(size, tid):
+            assert size > 0, 'size should be > 0'
             type_id = llop.extract_ushort(llgroup.HALFWORD, tid)
             has_finalizer = bool(tid & (1<<llgroup.HALFSHIFT))
             check_typeid(type_id)
@@ -620,6 +621,7 @@
         self.write_barrier_descr = WriteBarrierDescr(self)
         #
         def malloc_array(itemsize, tid, num_elem):
+            assert num_elem >= 0, 'num_elem should be >= 0'
             type_id = llop.extract_ushort(llgroup.HALFWORD, tid)
             check_typeid(type_id)
             try:
@@ -642,6 +644,7 @@
         unicode_type_id = self.layoutbuilder.get_type_id(rstr.UNICODE)
         #
         def malloc_str(length):
+            assert length >= 0, 'length should be >= 0'
             try:
                 return llop1.do_malloc_varsize_clear(
                     llmemory.GCREF,
@@ -651,6 +654,7 @@
                 fatalerror("out of memory (from JITted code)")
                 return lltype.nullptr(llmemory.GCREF.TO)
         def malloc_unicode(length):
+            assert length >= 0, 'length should be >= 0'
             try:
                 return llop1.do_malloc_varsize_clear(
                     llmemory.GCREF,


More information about the pypy-commit mailing list