[Bf-blender-cvs] [f16199d4791] blender2.8: Fix jumps-dependent-on-uninitialized-variable for iterators
Dalai Felinto
noreply at git.blender.org
Tue Nov 7 15:51:07 CET 2017
Commit: f16199d479189f1f142aebecf896182a7276c483
Author: Dalai Felinto
Date: Tue Nov 7 12:50:04 2017 -0200
Branches: blender2.8
https://developer.blender.org/rBf16199d479189f1f142aebecf896182a7276c483
Fix jumps-dependent-on-uninitialized-variable for iterators
We cannot have iter->valid unitialized, but we need to be sure it is set to true on begin.
Bug found by Sergey Sharybin.
===================================================================
M source/blender/blenkernel/intern/layer.c
M source/blender/blenlib/BLI_iterator.h
===================================================================
diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c
index f5650874ff0..2e1495b2e11 100644
--- a/source/blender/blenkernel/intern/layer.c
+++ b/source/blender/blenkernel/intern/layer.c
@@ -1800,6 +1800,7 @@ void BKE_renderable_objects_iterator_begin(BLI_Iterator *iter, void *data_in)
data->iter.set = NULL;
+ iter->valid = true;
iter->data = data_in;
BKE_renderable_objects_iterator_next(iter);
}
diff --git a/source/blender/blenlib/BLI_iterator.h b/source/blender/blenlib/BLI_iterator.h
index dffdeec949a..d8929b6e73a 100644
--- a/source/blender/blenlib/BLI_iterator.h
+++ b/source/blender/blenlib/BLI_iterator.h
@@ -43,10 +43,12 @@ typedef void (*IteratorBeginCb)(BLI_Iterator *iter, void *data_in);
IteratorCb callback_end_func = callback_end; \
BLI_Iterator iter_macro; \
iter_macro.skip = false; \
+ iter_macro.valid = false; \
for (callback_begin(&iter_macro, (_data_in)); \
iter_macro.valid; \
callback_next(&iter_macro)) \
{ \
+ BLI_assert(iter_macro.valid); \
if (iter_macro.skip) { \
iter_macro.skip = false; \
continue; \
More information about the Bf-blender-cvs
mailing list