Merged revisions 77508 via svnmerge from
authorAntoine Pitrou <solipsis@pitrou.net>
Fri, 15 Jan 2010 00:31:01 +0000 (00:31 +0000)
committerAntoine Pitrou <solipsis@pitrou.net>
Fri, 15 Jan 2010 00:31:01 +0000 (00:31 +0000)
svn+ssh://pythondev@svn.python.org/python/branches/py3k

................
  r77508 | antoine.pitrou | 2010-01-15 01:27:43 +0100 (ven., 15 janv. 2010) | 10 lines

  Merged revisions 77506 via svnmerge from
  svn+ssh://pythondev@svn.python.org/python/trunk

  ........
    r77506 | antoine.pitrou | 2010-01-15 01:18:00 +0100 (ven., 15 janv. 2010) | 4 lines

    Issue #7701: Fix crash in binascii.b2a_uu() in debug mode when given a
    1-byte argument.  Patch by Victor Stinner.
  ........
................

Lib/test/test_binascii.py
Misc/NEWS
Modules/binascii.c

index 65de81b8c100582cd3c1f8c6f62ea3554c133f2e..a35ec05633dbe8a9f6f0758302d233667ccbd844 100755 (executable)
@@ -103,6 +103,9 @@ class BinASCIITest(unittest.TestCase):
 
         self.assertRaises(binascii.Error, binascii.b2a_uu, 46*b"!")
 
+        # Issue #7701 (crash on a pydebug build)
+        self.assertEqual(binascii.b2a_uu(b'x'), b'!>   \n')
+
     def test_crc32(self):
         crc = binascii.crc32(b"Test the CRC-32 of")
         crc = binascii.crc32(b" this string.", crc)
index 36c232e3e2a6e939dcc3d97e163030f74c09938a..d0d761d1508a5fed5311d50b4add029dff25d330 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -65,6 +65,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #7701: Fix crash in binascii.b2a_uu() in debug mode when given a
+  1-byte argument.  Patch by Victor Stinner.
+
 - Issue #3299: Fix possible crash in the _sre module when given bad
   argument values in debug mode.  Patch by Victor Stinner.
 
index 51101b412a5bbb797d6eef2bf2c960f495d5c7cb..833283f7c983c1fd05154e7d4fb2bc65d042c12f 100644 (file)
@@ -294,7 +294,7 @@ binascii_b2a_uu(PyObject *self, PyObject *args)
        }
 
        /* We're lazy and allocate to much (fixed up later) */
-       if ( (rv=PyBytes_FromStringAndSize(NULL, bin_len*2+2)) == NULL ) {
+       if ( (rv=PyBytes_FromStringAndSize(NULL, 2 + (bin_len+2)/3*4)) == NULL ) {
                PyBuffer_Release(&pbin);
                return NULL;
        }