[Python-checkins] cpython (merge 3.2 -> default): Fix null pointer dereferencing in structmember.c PyMember_SetOne() for T_CHAR.

christian.heimes python-checkins at python.org
Tue Sep 11 17:31:32 CEST 2012


http://hg.python.org/cpython/rev/59ec0b9ff724
changeset:   78993:59ec0b9ff724
parent:      78991:c3539eb02470
parent:      78992:afe55cd04119
user:        Christian Heimes <christian at cheimes.de>
date:        Tue Sep 11 17:31:08 2012 +0200
summary:
  Fix null pointer dereferencing in structmember.c PyMember_SetOne() for T_CHAR. _PyUnicode_AsStringAndSize() can return NULL without touching the len argument. Also remove unnecessary PyUnicode_Check(), _PyUnicode_AsStringAndSize() performance the test again. CID 486815

files:
  Python/structmember.c |  6 +-----
  1 files changed, 1 insertions(+), 5 deletions(-)


diff --git a/Python/structmember.c b/Python/structmember.c
--- a/Python/structmember.c
+++ b/Python/structmember.c
@@ -254,12 +254,8 @@
         char *string;
         Py_ssize_t len;
 
-        if (!PyUnicode_Check(v)) {
-            PyErr_BadArgument();
-            return -1;
-        }
         string = _PyUnicode_AsStringAndSize(v, &len);
-        if (len != 1) {
+        if (string == NULL || len != 1) {
             PyErr_BadArgument();
             return -1;
         }

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


More information about the Python-checkins mailing list