mirror of
https://github.com/python/cpython.git
synced 2025-10-17 12:18:23 +00:00
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
This commit is contained in:
commit
e9a6d62d9f
1 changed files with 1 additions and 5 deletions
|
@ -254,12 +254,8 @@ PyMember_SetOne(char *addr, PyMemberDef *l, PyObject *v)
|
||||||
char *string;
|
char *string;
|
||||||
Py_ssize_t len;
|
Py_ssize_t len;
|
||||||
|
|
||||||
if (!PyUnicode_Check(v)) {
|
|
||||||
PyErr_BadArgument();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
string = _PyUnicode_AsStringAndSize(v, &len);
|
string = _PyUnicode_AsStringAndSize(v, &len);
|
||||||
if (len != 1) {
|
if (string == NULL || len != 1) {
|
||||||
PyErr_BadArgument();
|
PyErr_BadArgument();
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue