chiark
/
gitweb
/
~mdw
/
catacomb-python
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
2f9acb0
)
bytestring.c (bytestring_pyrepeat): Don't divide by zero.
author
Mark Wooding
<mdw@distorted.org.uk>
Fri, 11 Oct 2019 08:53:00 +0000
(09:53 +0100)
committer
Mark Wooding
<mdw@distorted.org.uk>
Sun, 17 Nov 2019 22:33:53 +0000
(22:33 +0000)
bytestring.c
patch
|
blob
|
blame
|
history
diff --git
a/bytestring.c
b/bytestring.c
index a7fe5cb6acf81e157eaf62eed4f72a7ed353447b..82d117f44fcf25bfbaf6fa853b3736005aace6da 100644
(file)
--- a/
bytestring.c
+++ b/
bytestring.c
@@
-165,7
+165,7
@@
static PyObject *bytestring_pyrepeat(PyObject *me, Py_ssize_t n)
xp = (const unsigned char *)PyString_AS_STRING(me);
xsz = PyString_GET_SIZE(me);
xp = (const unsigned char *)PyString_AS_STRING(me);
xsz = PyString_GET_SIZE(me);
- if (n < 0 ||
xsz >= (size_t)-1/n
) VALERR("too long");
+ if (n < 0 ||
(n && xsz >= (size_t)-1/n)
) VALERR("too long");
zsz = n*xsz; z = bytestring_pywrap(0, zsz); zp = PyString_AS_STRING(z);
if (xsz == 1) memset(zp, *xp, zsz);
else while (zsz) { memcpy(zp, xp, xsz); zp += xsz; zsz -= xsz; }
zsz = n*xsz; z = bytestring_pywrap(0, zsz); zp = PyString_AS_STRING(z);
if (xsz == 1) memset(zp, *xp, zsz);
else while (zsz) { memcpy(zp, xp, xsz); zp += xsz; zsz -= xsz; }