Skip to content

Commit 2e759a6

Browse files
committed
do not crash on __delitem__
1 parent 2079ca7 commit 2e759a6

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

src/c/_cffi_backend.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2609,6 +2609,11 @@ cdata_ass_slice(CDataObject *cd, PySliceObject *slice, PyObject *v)
26092609
cdata = cd->c_data + itemsize * bounds[0];
26102610
length = bounds[1];
26112611

2612+
if (v == NULL) {
2613+
PyErr_SetString(PyExc_TypeError,
2614+
"'del x[n]' not supported for cdata objects");
2615+
return -1;
2616+
}
26122617
if (CData_Check(v)) {
26132618
CTypeDescrObject *ctv = ((CDataObject *)v)->c_type;
26142619
if ((ctv->ct_flags & CT_ARRAY) && (ctv->ct_itemdescr == ct) &&

src/c/minibuffer.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,11 @@ static PyObject *mb_subscript(MiniBufferObj *self, PyObject *item)
243243
static int
244244
mb_ass_subscript(MiniBufferObj* self, PyObject* item, PyObject* value)
245245
{
246+
if (value == NULL) {
247+
PyErr_SetString(PyExc_TypeError,
248+
"'del x[n]' not supported for buffer objects");
249+
return -1;
250+
}
246251
if (PyIndex_Check(item)) {
247252
Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError);
248253
if (i == -1 && PyErr_Occurred())

0 commit comments

Comments
 (0)