From 2fdd76928f116a6e52e8f66669e8d76fcbe65ec6 Mon Sep 17 00:00:00 2001 From: David Mitchell Date: Wed, 9 Dec 2015 14:30:05 +0000 Subject: [PATCH] rpeep() assert oldoldop -> oldop -> o form a chain In rpeep(), in a loop, the var o becomes each op in the op_next chain in turn. At the same time, oldop is set to the previous value of o, and oldoldop the previous but one. Some places that modify the op_next chain weren't correctly upodating oldop and oldoldop at the same time. Last few commits have fixed those places. This commit adds an assert at the top of loop to check that oldoldop and oldop are in fact consistent. (This assert was used to find the faults fixed in the previous couple of commits). --- op.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/op.c b/op.c index 30595b7..0de303c 100644 --- a/op.c +++ b/op.c @@ -13127,6 +13127,11 @@ Perl_rpeep(pTHX_ OP *o) } redo: + + /* oldoldop -> oldop -> o should be a chain of 3 adjacent ops */ + assert(!oldoldop || oldoldop->op_next == oldop); + assert(!oldop || oldop->op_next == o); + /* By default, this op has now been optimised. A couple of cases below clear this again. */ o->op_opt = 1; -- 1.8.3.1