File tree Expand file tree Collapse file tree 1 file changed +8
-6
lines changed
Expand file tree Collapse file tree 1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -218,16 +218,18 @@ class reader_node : public observable_reader_node<T>
218218 needs_send_down_ = false ;
219219 needs_notify_ = true ;
220220
221- // We cannot use ranged-for here because children might
222- // change as a result of recompute(). This can invalidate
223- // the iterators on children, causing undefined behaviors.
224- // See also https://github.com/arximboldi/lager/pull/212
225221 const auto & children = this ->children ();
226- for (size_t i = 0 , size = children.size (); i < size; ++i) {
227- if (auto child = children[i].lock ()) {
222+ const size_t n_children = children.size ();
223+ for (auto & wchild : children) {
224+ if (auto child = wchild.lock ()) {
228225 child->send_down ();
229226 }
230227 }
228+ assert (n_children == children.size () &&
229+ " Children must not change during send_down, \
230+ because iterators would be invalidated leading to UB. \
231+ Maybe you created a new cursor inside a cursor.map(...) \
232+ call?" );
231233 }
232234 }
233235
You can’t perform that action at this time.
0 commit comments