Fix T89450: Crash slicing BMEditSelSeq
Slicing with indices greater than the length of the sequence would crash.
This commit is contained in:
parent
450593ddf0
commit
2b51124d6a
Notes:
blender-bot
2023-02-14 06:45:14 +01:00
Referenced by issue #88449, Blender LTS: Maintenance Task 2.93 Referenced by issue #89450, Slicing certain BMEditSelSeq objects crashes Blender Referenced by issue #77348, Blender LTS: Maintenance Task 2.83
|
@ -205,7 +205,6 @@ static PyObject *bpy_bmeditselseq_subscript_slice(BPy_BMEditSelSeq *self,
|
|||
Py_ssize_t stop)
|
||||
{
|
||||
int count = 0;
|
||||
bool ok;
|
||||
|
||||
PyObject *list;
|
||||
BMEditSelection *ese;
|
||||
|
@ -214,30 +213,22 @@ static PyObject *bpy_bmeditselseq_subscript_slice(BPy_BMEditSelSeq *self,
|
|||
|
||||
list = PyList_New(0);
|
||||
|
||||
ese = self->bm->selected.first;
|
||||
|
||||
ok = (ese != NULL);
|
||||
|
||||
if (UNLIKELY(ok == false)) {
|
||||
return list;
|
||||
}
|
||||
|
||||
/* first loop up-until the start */
|
||||
for (ok = true; ok; ok = ((ese = ese->next) != NULL)) {
|
||||
/* First loop up-until the start. */
|
||||
for (ese = self->bm->selected.first; ese; ese = ese->next) {
|
||||
if (count == start) {
|
||||
break;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
|
||||
/* add items until stop */
|
||||
do {
|
||||
/* Add items until stop. */
|
||||
for (; ese; ese = ese->next) {
|
||||
PyList_APPEND(list, BPy_BMElem_CreatePyObject(self->bm, &ese->ele->head));
|
||||
count++;
|
||||
if (count == stop) {
|
||||
break;
|
||||
}
|
||||
} while ((ese = ese->next));
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue