summaryrefslogtreecommitdiff
path: root/Python
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2012-09-11 17:31:08 +0200
committerChristian Heimes <christian@cheimes.de>2012-09-11 17:31:08 +0200
commitb3c186878a02884c990805a417b4c0652fc28abf (patch)
treeb056c15a038cb1dc09d22e66a74619c952f0b8ba /Python
parentf776a374171c3d6c9a95fdb92efd6a6b9ed413aa (diff)
parent1ad7c99984d34d6104de0848f7a12a27d81ba91a (diff)
downloadcpython-b3c186878a02884c990805a417b4c0652fc28abf.tar.gz
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')
-rw-r--r--Python/structmember.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/Python/structmember.c b/Python/structmember.c
index ddedea5419..af0296d802 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;
}