]> granicus.if.org Git - python/commitdiff
Merged revisions 77506 via svnmerge from
authorAntoine Pitrou <solipsis@pitrou.net>
Fri, 15 Jan 2010 00:23:22 +0000 (00:23 +0000)
committerAntoine Pitrou <solipsis@pitrou.net>
Fri, 15 Jan 2010 00:23:22 +0000 (00:23 +0000)
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 ea8be31c072da58d82cd7456f8efa91057ecd4c2..4ebf429ca6fe33634b464d68019125a028266243 100755 (executable)
@@ -104,6 +104,9 @@ class BinASCIITest(unittest.TestCase):
 
         self.assertRaises(binascii.Error, binascii.b2a_uu, 46*"!")
 
+        # Issue #7701 (crash on a pydebug build)
+        self.assertEqual(binascii.b2a_uu('x'), '!>   \n')
+
     def test_crc32(self):
         crc = binascii.crc32("Test the CRC-32 of")
         crc = binascii.crc32(" this string.", crc)
index a292c74fd3e8eae3ccc3df6fedc82cf0a23f4abd..c9b15b0b616096ae17110718fb122c412fe4e875 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -48,6 +48,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 bcbafcffa9dd3e53ab9f7339328368fc17608f72..65471a65a2a15c6e63bf7a8d5f75e719ec84f9b2 100644 (file)
@@ -282,7 +282,7 @@ binascii_b2a_uu(PyObject *self, PyObject *args)
        }
 
        /* We're lazy and allocate to much (fixed up later) */
-       if ( (rv=PyString_FromStringAndSize(NULL, bin_len*2+2)) == NULL )
+       if ( (rv=PyString_FromStringAndSize(NULL, 2 + (bin_len+2)/3*4)) == NULL )
                return NULL;
        ascii_data = (unsigned char *)PyString_AsString(rv);