diff options
author | Christian Heimes <christian@cheimes.de> | 2012-09-11 15:30:53 (GMT) |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2012-09-11 15:30:53 (GMT) |
commit | 5557a9c73fc52276c3fb382491b3f9fe5999a042 (patch) | |
tree | ee81750e352588c2180ea3910e494638ac136241 /Python/structmember.c | |
parent | 2fd8bdbc9d904a7cb9f7cd676322eee03d92ee0c (diff) | |
download | cpython-5557a9c73fc52276c3fb382491b3f9fe5999a042.zip cpython-5557a9c73fc52276c3fb382491b3f9fe5999a042.tar.gz cpython-5557a9c73fc52276c3fb382491b3f9fe5999a042.tar.bz2 |
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
Diffstat (limited to 'Python/structmember.c')
-rw-r--r-- | Python/structmember.c | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/Python/structmember.c b/Python/structmember.c index ddedea5..af0296d 100644 --- a/Python/structmember.c +++ b/Python/structmember.c @@ -254,12 +254,8 @@ PyMember_SetOne(char *addr, PyMemberDef *l, PyObject *v) 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; } |