diff options
-rw-r--r-- | generic/tclCompile.c | 2 | ||||
-rw-r--r-- | tests/for.test | 40 |
2 files changed, 41 insertions, 1 deletions
diff --git a/generic/tclCompile.c b/generic/tclCompile.c index 824276c..478881d 100644 --- a/generic/tclCompile.c +++ b/generic/tclCompile.c @@ -4101,7 +4101,7 @@ TclEmitInvoke( && auxContinuePtr->expandTarget == envPtr->expandCount-expandCount) { auxContinuePtr = NULL; } else { - continueRange = auxBreakPtr - envPtr->exceptAuxArrayPtr; + continueRange = auxContinuePtr - envPtr->exceptAuxArrayPtr; } if (auxBreakPtr != NULL || auxContinuePtr != NULL) { diff --git a/tests/for.test b/tests/for.test index 8abd270..cd34781 100644 --- a/tests/for.test +++ b/tests/for.test @@ -1184,6 +1184,46 @@ test for-7.24 {Bug 3614226: ensure that continue from expanded command only clea expr {$end - $tmp} }} {return -level 0 -code continue} } 0 + +test for-8.0 {Coverity CID 1251203: break vs continue in for-step clause} { + apply {{} { + for {set k 0} {$k < 3} {incr k} { + set j 0 + list a [\ + for {set i 0} {$i < 5} {incr i; list a [eval {}]} { + incr j + }] + incr i + } + list $i $j $k + }} +} {6 5 3} +test for-8.1 {Coverity CID 1251203: break vs continue in for-step clause} { + apply {{} { + for {set k 0} {$k < 3} {incr k} { + set j 0 + list a [\ + for {set i 0} {$i < 5} {incr i;list a [eval break]} { + incr j + }] + incr i + } + list $i $j $k + }} +} {2 1 3} +test for-8.2 {Coverity CID 1251203: break vs continue in for-step clause} { + apply {{} { + for {set k 0} {$k < 3} {incr k} { + set j 0 + list a [\ + for {set i 0} {$i < 5} {incr i;list a [eval continue]} { + incr j + }] + incr i + } + list $i $j $k + }} +} {1 1 3} # cleanup ::tcltest::cleanupTests |