[pypy-svn] r28820 - pypy/dist/pypy/objspace/std
ac at codespeak.net
ac at codespeak.net
Thu Jun 15 15:44:56 CEST 2006
Author: ac
Date: Thu Jun 15 15:44:56 2006
New Revision: 28820
Modified:
pypy/dist/pypy/objspace/std/unicodeobject.py
Log:
Check for overflow when multiplying unicodestrings.
Modified: pypy/dist/pypy/objspace/std/unicodeobject.py
==============================================================================
--- pypy/dist/pypy/objspace/std/unicodeobject.py (original)
+++ pypy/dist/pypy/objspace/std/unicodeobject.py Thu Jun 15 15:44:56 2006
@@ -3,7 +3,7 @@
from pypy.objspace.std.stringobject import W_StringObject
from pypy.objspace.std.noneobject import W_NoneObject
from pypy.objspace.std.sliceobject import W_SliceObject
-from pypy.rpython.rarithmetic import intmask
+from pypy.rpython.rarithmetic import intmask, ovfcheck
from pypy.module.unicodedata import unicodedb_4_1_0 as unicodedb
class W_UnicodeObject(W_Object):
@@ -248,8 +248,9 @@
return W_UnicodeObject([w_uni._value[0]] * times)
try:
- result = [u'\0'] * (charlen * times)
- except OverflowError:
+ result_size = ovfcheck(charlen * times)
+ result = [u'\0'] * result_size
+ except (OverflowError, MemoryError):
raise OperationError(space.w_OverflowError, space.wrap('repeated string is too long'))
for i in range(times):
offset = i * charlen
More information about the Pypy-commit
mailing list