diff Python/structmember.c @ 78992:afe55cd04119 3.2

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
author Christian Heimes <christian@cheimes.de>
date Tue, 11 Sep 2012 17:30:53 +0200
parents 3c9232a684ae
children
line wrap: on
line diff
--- a/Python/structmember.c	Tue Sep 11 03:17:52 2012 -0700
+++ b/Python/structmember.c	Tue Sep 11 17:30:53 2012 +0200
@@ -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;
         }