Skip to content

Commit 925ada5

Browse files
committed
fix possible NULL pointer dereference
1 parent 969631a commit 925ada5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Modules/_ctypes/_ctypes.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2826,6 +2826,7 @@ PyCData_NewGetBuffer(PyObject *myself, Py_buffer *view, int flags)
28262826
StgDictObject *item_dict = PyType_stgdict(item_type);
28272827

28282828
if (view == NULL) return 0;
2829+
assert(dict);
28292830

28302831
view->buf = self->b_ptr;
28312832
view->obj = Py_NewRef(myself);
@@ -2862,7 +2863,10 @@ PyCData_reduce(PyObject *myself, PyObject *args)
28622863
{
28632864
CDataObject *self = (CDataObject *)myself;
28642865

2865-
if (PyObject_stgdict(myself)->flags & (TYPEFLAG_ISPOINTER|TYPEFLAG_HASPOINTER)) {
2866+
StgDictObject *stgdict = PyObject_stgdict(myself);
2867+
assert(stgdict);
2868+
2869+
if (stgdict->flags & (TYPEFLAG_ISPOINTER|TYPEFLAG_HASPOINTER)) {
28662870
PyErr_SetString(PyExc_ValueError,
28672871
"ctypes objects containing pointers cannot be pickled");
28682872
return NULL;

0 commit comments

Comments
 (0)