[Python-checkins] cpython (merge 3.2 -> default): Merge 3.2.

stefan.krah python-checkins at python.org
Mon Aug 20 11:20:15 CEST 2012


http://hg.python.org/cpython/rev/2af78f8a98e1
changeset:   78668:2af78f8a98e1
parent:      78666:717344a837ab
parent:      78667:cfddcf964ff0
user:        Stefan Krah <skrah at bytereef.org>
date:        Mon Aug 20 11:13:58 2012 +0200
summary:
  Merge 3.2.

files:
  Lib/test/test_capi.py |  13 +++++++++++++
  Objects/abstract.c    |   5 +++++
  2 files changed, 18 insertions(+), 0 deletions(-)


diff --git a/Lib/test/test_capi.py b/Lib/test/test_capi.py
--- a/Lib/test/test_capi.py
+++ b/Lib/test/test_capi.py
@@ -11,6 +11,10 @@
 import unittest
 from test import support
 try:
+    import _posixsubprocess
+except ImportError:
+    _posixsubprocess = None
+try:
     import threading
 except ImportError:
     threading = None
@@ -78,6 +82,15 @@
         else:
             self.assertTrue(False)
 
+    @unittest.skipUnless(_posixsubprocess, '_posixsubprocess required for this test.')
+    def test_seq_bytes_to_charp_array(self):
+        # Issue #15732: crash in _PySequence_BytesToCharpArray()
+        class Z(object):
+            def __len__(self):
+                return 1
+        self.assertRaises(TypeError, _posixsubprocess.fork_exec,
+                          1,Z(),3,[1, 2],5,6,7,8,9,10,11,12,13,14,15,16,17)
+
 @unittest.skipUnless(threading, 'Threading required for this test.')
 class TestPendingCalls(unittest.TestCase):
 
diff --git a/Objects/abstract.c b/Objects/abstract.c
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -2718,6 +2718,11 @@
     for (i = 0; i < argc; ++i) {
         char *data;
         item = PySequence_GetItem(self, i);
+        if (item == NULL) {
+            /* NULL terminate before freeing. */
+            array[i] = NULL;
+            goto fail;
+        }
         data = PyBytes_AsString(item);
         if (data == NULL) {
             /* NULL terminate before freeing. */

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list