mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #28715: Added error checks for PyUnicode_AsUTF8().
This commit is contained in:
commit
f6f1591808
5 changed files with 20 additions and 10 deletions
|
@ -728,8 +728,7 @@ PyCStructType_setattro(PyObject *self, PyObject *key, PyObject *value)
|
|||
return -1;
|
||||
|
||||
if (value && PyUnicode_Check(key) &&
|
||||
/* XXX struni _PyUnicode_AsString can fail (also in other places)! */
|
||||
0 == strcmp(_PyUnicode_AsString(key), "_fields_"))
|
||||
_PyUnicode_EqualToASCIIString(key, "_fields_"))
|
||||
return PyCStructUnionType_update_stgdict(self, value, 1);
|
||||
return 0;
|
||||
}
|
||||
|
@ -743,7 +742,7 @@ UnionType_setattro(PyObject *self, PyObject *key, PyObject *value)
|
|||
return -1;
|
||||
|
||||
if (PyUnicode_Check(key) &&
|
||||
0 == strcmp(_PyUnicode_AsString(key), "_fields_"))
|
||||
_PyUnicode_EqualToASCIIString(key, "_fields_"))
|
||||
return PyCStructUnionType_update_stgdict(self, value, 0);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1666,7 +1666,9 @@ POINTER(PyObject *self, PyObject *cls)
|
|||
return result;
|
||||
}
|
||||
if (PyUnicode_CheckExact(cls)) {
|
||||
char *name = _PyUnicode_AsString(cls);
|
||||
const char *name = PyUnicode_AsUTF8(cls);
|
||||
if (name == NULL)
|
||||
return NULL;
|
||||
buf = PyMem_Malloc(strlen(name) + 3 + 1);
|
||||
if (buf == NULL)
|
||||
return PyErr_NoMemory();
|
||||
|
|
|
@ -929,11 +929,14 @@ static PyMethodDef oss_mixer_methods[] = {
|
|||
static PyObject *
|
||||
oss_getattro(oss_audio_t *self, PyObject *nameobj)
|
||||
{
|
||||
char *name = "";
|
||||
const char *name = "";
|
||||
PyObject * rval = NULL;
|
||||
|
||||
if (PyUnicode_Check(nameobj))
|
||||
name = _PyUnicode_AsString(nameobj);
|
||||
if (PyUnicode_Check(nameobj)) {
|
||||
name = PyUnicode_AsUTF8(nameobj);
|
||||
if (name == NULL)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (strcmp(name, "closed") == 0) {
|
||||
rval = (self->fd == -1) ? Py_True : Py_False;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue