Commits

Antonio Cuni committed da06934

one more overlapping case to detect

Comments (0)

Files changed (2)

pypy/jit/metainterp/optimizeopt/rawbuffer.py

             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
         #
         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)

pypy/jit/metainterp/optimizeopt/test/test_rawbuffer.py

         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')