Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e9a6d62

Browse files
committed
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
2 parents 6d29352 + 5557a9c commit e9a6d62

1 file changed

Lines changed: 1 addition & 5 deletions

File tree

Python/structmember.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,12 +254,8 @@ PyMember_SetOne(char *addr, PyMemberDef *l, PyObject *v)
254254
char *string;
255255
Py_ssize_t len;
256256

257-
if (!PyUnicode_Check(v)) {
258-
PyErr_BadArgument();
259-
return -1;
260-
}
261257
string = _PyUnicode_AsStringAndSize(v, &len);
262-
if (len != 1) {
258+
if (string == NULL || len != 1) {
263259
PyErr_BadArgument();
264260
return -1;
265261
}

0 commit comments

Comments
 (0)