Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Modules/_ctypes/_ctypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -409,9 +409,11 @@ typedef struct {
#define _StructParamObject_CAST(op) ((StructParamObject *)(op))

static int
StructParam_traverse(PyObject *self, visitproc visit, void *arg)
StructParam_traverse(PyObject *myself, visitproc visit, void *arg)
{
StructParamObject *self = _StructParamObject_CAST(myself);
Py_VISIT(Py_TYPE(self));
Py_VISIT(self->keep);
return 0;
}

Expand Down Expand Up @@ -2377,6 +2379,7 @@ PyCSimpleType_init(PyObject *self, PyObject *args, PyObject *kwds)
}
StgInfo *sw_info;
if (PyStgInfo_FromType(st, swapped, &sw_info) < 0) {
Py_DECREF(swapped);
return -1;
}
assert(sw_info);
Expand Down Expand Up @@ -2673,6 +2676,7 @@ make_funcptrtype_dict(ctypes_state *st, PyObject *attrdict, StgInfo *stginfo)
if (ob) {
StgInfo *info;
if (PyStgInfo_FromType(st, ob, &info) < 0) {
Py_DECREF(ob);
return -1;
}
if (ob != Py_None && !info && !PyCallable_Check(ob)) {
Expand Down Expand Up @@ -5649,6 +5653,10 @@ Pointer_subscript(PyObject *myself, PyObject *item)

for (cur = start, i = 0; i < len; cur += step, i++) {
PyObject *v = Pointer_item(myself, cur);
if (!v) {
Py_DECREF(np);
return NULL;
}
PyList_SET_ITEM(np, i, v);
}
return np;
Expand Down
24 changes: 12 additions & 12 deletions Modules/_ctypes/stgdict.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ PyCStructUnionType_update_stginfo(PyObject *type, PyObject *fields, int isStruct
// They're cleared on error.
PyObject *layout_func = NULL;
PyObject *kwnames = NULL;
PyObject* align = NULL;
PyObject* size = NULL;
PyObject *align_obj = NULL;
PyObject *size_obj = NULL;
PyObject *layout_fields_obj = NULL;
PyObject *layout_fields = NULL;
PyObject *layout = NULL;
Expand Down Expand Up @@ -291,12 +291,12 @@ PyCStructUnionType_update_stginfo(PyObject *type, PyObject *fields, int isStruct
goto error;
}

align = PyObject_GetAttr(layout, &_Py_ID(align));
if (!align) {
align_obj = PyObject_GetAttr(layout, &_Py_ID(align));
if (!align_obj) {
goto error;
}
Py_ssize_t total_align = PyLong_AsSsize_t(align);
Py_CLEAR(align);
Py_ssize_t total_align = PyLong_AsSsize_t(align_obj);
Py_CLEAR(align_obj);
if (total_align < 0) {
if (!PyErr_Occurred()) {
PyErr_SetString(PyExc_ValueError,
Expand All @@ -305,12 +305,12 @@ PyCStructUnionType_update_stginfo(PyObject *type, PyObject *fields, int isStruct
goto error;
}

size = PyObject_GetAttr(layout, &_Py_ID(size));
if (!size) {
size_obj = PyObject_GetAttr(layout, &_Py_ID(size));
if (!size_obj) {
goto error;
}
Py_ssize_t total_size = PyLong_AsSsize_t(size);
Py_CLEAR(size);
Py_ssize_t total_size = PyLong_AsSsize_t(size_obj);
Py_CLEAR(size_obj);
if (total_size < 0) {
if (!PyErr_Occurred()) {
PyErr_SetString(PyExc_ValueError,
Expand Down Expand Up @@ -669,8 +669,8 @@ PyCStructUnionType_update_stginfo(PyObject *type, PyObject *fields, int isStruct
error:
Py_XDECREF(layout_func);
Py_XDECREF(kwnames);
Py_XDECREF(align);
Py_XDECREF(size);
Py_XDECREF(align_obj);
Py_XDECREF(size_obj);
Py_XDECREF(layout_fields_obj);
Py_XDECREF(layout_fields);
Py_XDECREF(layout);
Expand Down
Loading