Commits

Philip Jenvey  committed 87aa9de

avoid a fail attempt to copy nothing to a nullptr buffer
(grafted from 8d0da723fb85a16a3c850f2d7ed6d98b967cb6e2)

  • Participants
  • Parent commits 11ffafd
  • Branches release-2.2.x
  • Tags release-2.2.1

Comments (0)

Files changed (2)

File pypy/module/array/interp_array.py

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

File pypy/module/array/test/test_array.py

         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)