[pypy-svn] r59401 - in pypy/trunk/pypy: rpython/lltypesystem translator/c/test
fijal at codespeak.net
fijal at codespeak.net
Sat Oct 25 15:28:40 CEST 2008
Author: fijal
Date: Sat Oct 25 15:28:40 2008
New Revision: 59401
Modified:
pypy/trunk/pypy/rpython/lltypesystem/rstr.py
pypy/trunk/pypy/translator/c/test/test_overflow.py
Log:
another test and fix
Modified: pypy/trunk/pypy/rpython/lltypesystem/rstr.py
==============================================================================
--- pypy/trunk/pypy/rpython/lltypesystem/rstr.py (original)
+++ pypy/trunk/pypy/rpython/lltypesystem/rstr.py Sat Oct 25 15:28:40 2008
@@ -354,10 +354,17 @@
return s.empty()
itemslen = 0
i = 0
- while i < num_items:
- itemslen += len(items[i].chars)
- i += 1
- result = s.malloc(itemslen + s_len * (num_items - 1))
+ try:
+ while i < num_items:
+ lgt = len(items[i].chars)
+ itemslen = ovfcheck(itemslen + lgt)
+ i += 1
+ num_items_1 = num_items - 1
+ totalmalloc = ovfcheck(s_len * num_items_1)
+ totalmalloc = ovfcheck(itemslen + totalmalloc)
+ except OverflowError:
+ raise
+ result = s.malloc(totalmalloc)
res_index = len(items[0].chars)
s.copy_contents(items[0], result, 0, 0, res_index)
i = 1
Modified: pypy/trunk/pypy/translator/c/test/test_overflow.py
==============================================================================
--- pypy/trunk/pypy/translator/c/test/test_overflow.py (original)
+++ pypy/trunk/pypy/translator/c/test/test_overflow.py Sat Oct 25 15:28:40 2008
@@ -8,7 +8,7 @@
from pypy.translator.c.test.test_boehm import AbstractGCTestClass
class TestOverflow(AbstractGCTestClass):
- def test_overflow(self):
+ def test_ll_join_strs(self):
def f(i):
x = "A" * (2 << i)
''.join([x] * (2 << i))
@@ -17,3 +17,12 @@
py.test.raises(OverflowError, fn, 16)
# XXX - we cannot grab overflow check inside test, for obscure
# graph related reasons it gets propagated anyway
+
+ def test_ll_join(self):
+ def f(i):
+ x = "A" * (2 << i)
+ 'a'.join([x] * (2 << i))
+
+ fn = self.getcompiled(f, [int])
+ py.test.raises(OverflowError, fn, 16)
+
More information about the Pypy-commit
mailing list