[Bf-blender-cvs] [a609e9f07ff] blender-v2.83-release: Fix T89450: Crash slicing BMEditSelSeq
Campbell Barton
noreply at git.blender.org
Mon Aug 16 10:02:39 CEST 2021
Commit: a609e9f07ff9732b85aff2bdfe169ea785aac626
Author: Campbell Barton
Date: Thu Aug 5 16:44:01 2021 +1000
Branches: blender-v2.83-release
https://developer.blender.org/rBa609e9f07ff9732b85aff2bdfe169ea785aac626
Fix T89450: Crash slicing BMEditSelSeq
Slicing with indices greater than the length of the sequence would crash.
===================================================================
M source/blender/python/bmesh/bmesh_py_types_select.c
===================================================================
diff --git a/source/blender/python/bmesh/bmesh_py_types_select.c b/source/blender/python/bmesh/bmesh_py_types_select.c
index c41459f1f1e..38f0c20de47 100644
--- a/source/blender/python/bmesh/bmesh_py_types_select.c
+++ b/source/blender/python/bmesh/bmesh_py_types_select.c
@@ -207,7 +207,6 @@ static PyObject *bpy_bmeditselseq_subscript_slice(BPy_BMEditSelSeq *self,
Py_ssize_t stop)
{
int count = 0;
- bool ok;
PyObject *list;
BMEditSelection *ese;
@@ -216,30 +215,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;
}
More information about the Bf-blender-cvs
mailing list