Author: Antonio Cuni <[email protected]>
Branch: virtual-raw-mallocs
Changeset: r59488:da06934804f0
Date: 2012-12-18 18:01 +0100
http://bitbucket.org/pypy/pypy/changeset/da06934804f0/

Log:    one more overlapping case to detect

diff --git a/pypy/jit/metainterp/optimizeopt/rawbuffer.py 
b/pypy/jit/metainterp/optimizeopt/rawbuffer.py
--- a/pypy/jit/metainterp/optimizeopt/rawbuffer.py
+++ b/pypy/jit/metainterp/optimizeopt/rawbuffer.py
@@ -34,7 +34,7 @@
             if self.offsets[i] == offset:
                 if length != self.lengths[i] or descr != self.descrs[i]:
                     # in theory we could add support for the cases in which
-                    # the lenght or descr is different, but I don't think we
+                    # the length or descr is different, but I don't think we
                     # need it in practice
                     raise InvalidRawWrite
                 # update the value at this offset
@@ -46,6 +46,8 @@
         #
         if i < len(self.offsets) and offset+length > self.offsets[i]:
             raise InvalidRawWrite
+        if i > 0 and self.offsets[i-1]+self.lengths[i-1] > offset:
+            raise InvalidRawWrite
         # insert a new value at offset
         self.offsets.insert(i, offset)
         self.lengths.insert(i, length)
diff --git a/pypy/jit/metainterp/optimizeopt/test/test_rawbuffer.py 
b/pypy/jit/metainterp/optimizeopt/test/test_rawbuffer.py
--- a/pypy/jit/metainterp/optimizeopt/test/test_rawbuffer.py
+++ b/pypy/jit/metainterp/optimizeopt/test/test_rawbuffer.py
@@ -35,13 +35,19 @@
         buf.write_value(0, 4, 'descr2', 'two')
 
     
-def test_write_value_overlapping():
+def test_write_value_overlapping_next():
     buf = RawBuffer()
     buf.write_value(0, 4, 'descr', 'one')
     buf.write_value(6, 4, 'descr', 'two')
     with py.test.raises(InvalidRawWrite):
         buf.write_value(4, 4, 'descr', 'three')
 
+def test_write_value_overlapping_prev():
+    buf = RawBuffer()
+    buf.write_value(0, 4, 'descr', 'one')
+    with py.test.raises(InvalidRawWrite):
+        buf.write_value(2, 1, 'descr', 'two')
+
 def test_read_value():
     buf = RawBuffer()
     buf.write_value(0, 4, 'descr', 'one')
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to