Fix T89450: Crash slicing BMEditSelSeq
Slicing with indices greater than the length of the sequence would crash.
This commit is contained in:
@@ -205,7 +205,6 @@ static PyObject *bpy_bmeditselseq_subscript_slice(BPy_BMEditSelSeq *self,
|
|||||||
Py_ssize_t stop)
|
Py_ssize_t stop)
|
||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
bool ok;
|
|
||||||
|
|
||||||
PyObject *list;
|
PyObject *list;
|
||||||
BMEditSelection *ese;
|
BMEditSelection *ese;
|
||||||
@@ -214,30 +213,22 @@ static PyObject *bpy_bmeditselseq_subscript_slice(BPy_BMEditSelSeq *self,
|
|||||||
|
|
||||||
list = PyList_New(0);
|
list = PyList_New(0);
|
||||||
|
|
||||||
ese = self->bm->selected.first;
|
/* First loop up-until the start. */
|
||||||
|
for (ese = self->bm->selected.first; ese; ese = ese->next) {
|
||||||
ok = (ese != NULL);
|
|
||||||
|
|
||||||
if (UNLIKELY(ok == false)) {
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* first loop up-until the start */
|
|
||||||
for (ok = true; ok; ok = ((ese = ese->next) != NULL)) {
|
|
||||||
if (count == start) {
|
if (count == start) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add items until stop */
|
/* Add items until stop. */
|
||||||
do {
|
for (; ese; ese = ese->next) {
|
||||||
PyList_APPEND(list, BPy_BMElem_CreatePyObject(self->bm, &ese->ele->head));
|
PyList_APPEND(list, BPy_BMElem_CreatePyObject(self->bm, &ese->ele->head));
|
||||||
count++;
|
count++;
|
||||||
if (count == stop) {
|
if (count == stop) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} while ((ese = ese->next));
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user