summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_ctypes/_ctypes.c16
-rw-r--r--Modules/_ctypes/cfield.c5
-rw-r--r--Modules/socketmodule.c12
3 files changed, 27 insertions, 6 deletions
diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c
index 54e7963..dd4b754 100644
--- a/Modules/_ctypes/_ctypes.c
+++ b/Modules/_ctypes/_ctypes.c
@@ -783,6 +783,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,
@@ -838,6 +844,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,
@@ -4022,6 +4033,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 f29fc666..a873642 100644
--- a/Modules/_ctypes/cfield.c
+++ b/Modules/_ctypes/cfield.c
@@ -195,6 +195,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);
}
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index c1fb5aa..ddffd23 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -2181,12 +2181,12 @@ See recv() for documentation about the flags.");
/*
- * This is the guts of the recv() and recv_into() methods, which reads into a
- * char buffer. If you have any inc/def ref to do to the objects that contain
- * the buffer, do it in the caller. This function returns the number of bytes
- * succesfully read. If there was an error, it returns -1. Note that it is
- * also possible that we return a number of bytes smaller than the request
- * bytes.
+ * This is the guts of the recvfrom() and recvfrom_into() methods, which reads
+ * into a char buffer. If you have any inc/def ref to do to the objects that
+ * contain the buffer, do it in the caller. This function returns the number
+ * of bytes succesfully read. If there was an error, it returns -1. Note
+ * that it is also possible that we return a number of bytes smaller than the
+ * request bytes.
*
* 'addr' is a return value for the address object. Note that you must decref
* it yourself.