[pypy-commit] pypy release-2.2.x: avoid a fail attempt to copy nothing to a nullptr buffer
pjenvey
noreply at buildbot.pypy.org
Sun Nov 24 19:34:14 CET 2013
Author: Philip Jenvey <pjenvey at underboss.org>
Branch: release-2.2.x
Changeset: r68312:87aa9de10f9c
Date: 2013-11-15 11:44 -0800
http://bitbucket.org/pypy/pypy/changeset/87aa9de10f9c/
Log: avoid a fail attempt to copy nothing to a nullptr buffer (grafted
from 8d0da723fb85a16a3c850f2d7ed6d98b967cb6e2)
diff --git a/pypy/module/array/interp_array.py b/pypy/module/array/interp_array.py
--- a/pypy/module/array/interp_array.py
+++ b/pypy/module/array/interp_array.py
@@ -236,6 +236,8 @@
raise OperationError(self.space.w_ValueError, self.space.wrap(msg))
oldlen = self.len
new = len(s) / self.itemsize
+ if not new:
+ return
self.setlen(oldlen + new)
cbuf = self._charbuf_start()
copy_string_to_raw(llstr(s), rffi.ptradd(cbuf, oldlen * self.itemsize), 0, len(s))
diff --git a/pypy/module/array/test/test_array.py b/pypy/module/array/test/test_array.py
--- a/pypy/module/array/test/test_array.py
+++ b/pypy/module/array/test/test_array.py
@@ -171,6 +171,9 @@
a = self.array('c')
a.fromstring('Hi!')
assert a[0] == 'H' and a[1] == 'i' and a[2] == '!' and len(a) == 3
+ a = self.array('c')
+ a.fromstring('')
+ assert not len(a)
for t in 'bBhHiIlLfd':
a = self.array(t)
More information about the pypy-commit
mailing list