diff options
author | Campbell Barton <ideasman42@gmail.com> | 2021-08-05 09:44:01 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2021-08-09 09:01:19 +0300 |
commit | f6665f506b0a7cb5251501eca37a8e2e9d7bafc1 (patch) | |
tree | 841eccfa62c6681eb07ae5df12679a042245848f | |
parent | e862874606b9f1a8477c345b23fb39e53e4a9390 (diff) |
Fix T89450: Crash slicing BMEditSelSeq
Slicing with indices greater than the length of the sequence would crash.
-rw-r--r-- | source/blender/python/bmesh/bmesh_py_types_select.c | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/source/blender/python/bmesh/bmesh_py_types_select.c b/source/blender/python/bmesh/bmesh_py_types_select.c index 69f104c9959..b89822a080c 100644 --- a/source/blender/python/bmesh/bmesh_py_types_select.c +++ b/source/blender/python/bmesh/bmesh_py_types_select.c @@ -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; } |