diff options
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_ctypes/_ctypes.c | 16 | ||||
-rw-r--r-- | Modules/_ctypes/cfield.c | 5 |
2 files changed, 21 insertions, 0 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index d564fb9..03e2e7a 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -788,6 +788,12 @@ CharArray_set_value(CDataObject *self, PyObject *value) char *ptr; Py_ssize_t size; + if (value == NULL) { + PyErr_SetString(PyExc_TypeError, + "can't delete attribute"); + return -1; + } + if (PyUnicode_Check(value)) { value = PyUnicode_AsEncodedString(value, conversion_mode_encoding, @@ -843,6 +849,11 @@ WCharArray_set_value(CDataObject *self, PyObject *value) { Py_ssize_t result = 0; + if (value == NULL) { + PyErr_SetString(PyExc_TypeError, + "can't delete attribute"); + return -1; + } if (PyString_Check(value)) { value = PyUnicode_FromEncodedObject(value, conversion_mode_encoding, @@ -4139,6 +4150,11 @@ Simple_set_value(CDataObject *self, PyObject *value) PyObject *result; StgDictObject *dict = PyObject_stgdict((PyObject *)self); + if (value == NULL) { + PyErr_SetString(PyExc_TypeError, + "can't delete attribute"); + return -1; + } assert(dict); /* Cannot be NULL for CDataObject instances */ assert(dict->setfunc); result = dict->setfunc(self->b_ptr, value, dict->size); diff --git a/Modules/_ctypes/cfield.c b/Modules/_ctypes/cfield.c index 77667f5..8857e44 100644 --- a/Modules/_ctypes/cfield.c +++ b/Modules/_ctypes/cfield.c @@ -199,6 +199,11 @@ CField_set(CFieldObject *self, PyObject *inst, PyObject *value) assert(CDataObject_Check(inst)); dst = (CDataObject *)inst; ptr = dst->b_ptr + self->offset; + if (value == NULL) { + PyErr_SetString(PyExc_TypeError, + "can't delete attribute"); + return -1; + } return CData_set(inst, self->proto, self->setfunc, value, self->index, self->size, ptr); } |