]> granicus.if.org Git - python/commitdiff
Backport checkin:
authorWalter Dörwald <walter@livinglogic.de>
Wed, 9 May 2007 18:13:53 +0000 (18:13 +0000)
committerWalter Dörwald <walter@livinglogic.de>
Wed, 9 May 2007 18:13:53 +0000 (18:13 +0000)
Fix a segfault when b"" was passed to b2a_qp() -- it was using strchr()
instead of memchr().

Modules/binascii.c

index 91309f673bb4e417a8bf04948ff4bb4b4d390b8c..00f950d19da426bc4d282004f3be270b0e1ee248 100644 (file)
@@ -1150,7 +1150,7 @@ binascii_b2a_qp (PyObject *self, PyObject *args, PyObject *kwargs)
        /* XXX: this function has the side effect of converting all of
         * the end of lines to be the same depending on this detection
         * here */
-       p = (unsigned char *) strchr((char *)data, '\n');
+       p = (unsigned char *) memchr(data, '\n', datalen);
        if ((p != NULL) && (p > data) && (*(p-1) == '\r'))
                crlf = 1;