From 5557a9c73fc52276c3fb382491b3f9fe5999a042 Mon Sep 17 00:00:00 2001 From: Christian Heimes Date: Tue, 11 Sep 2012 17:30:53 +0200 Subject: 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 --- Python/structmember.c | 6 +----- 1 file changed, 1 insertion(+), 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; } -- cgit v0.12