From abd4f23414e9e8d5dfa677f4b43de757b6954b3c Mon Sep 17 00:00:00 2001 From: TimePath Date: Wed, 27 Jul 2016 22:14:53 +1000 Subject: [PATCH] Loops: copy reference to next entity before entering lambda --- qcsrc/lib/iter.qh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/qcsrc/lib/iter.qh b/qcsrc/lib/iter.qh index c21d02121..82448b931 100644 --- a/qcsrc/lib/iter.qh +++ b/qcsrc/lib/iter.qh @@ -23,10 +23,11 @@ MACRO_BEGIN \ { \ int _i = 0; \ - for (entity _it = list##_first; _it; (_it = _it.next, ++_i)) \ + for (entity _it = list##_first, _next = NULL; _it; (_it = _next, ++_i)) \ { \ const noref int i = _i; \ ITER_CONST noref entity it = _it; \ + _next = _it.next; \ if (cond) { LAMBDA(body) } \ } \ } MACRO_END -- 2.39.2