Conditionals must not straddle two scripts.

Found by tests dhill is working on. We checked that ifs were closed at the end
of execution but not at script switching time, we now move this to just after
finishing a single script.
This commit is contained in:
Owain G. Ainsworth 2014-03-14 14:52:22 +00:00
parent 8df0af32d6
commit c1a6e47f38

View file

@ -583,10 +583,6 @@ func (s *Script) CheckErrorCondition() (err error) {
}))
err = StackErrScriptFailed
}
if err == nil && len(s.condStack) != 1 {
// conditional execution stack context left active
err = StackErrMissingEndif
}
return err
}
@ -625,6 +621,11 @@ func (m *Script) Step() (done bool, err error) {
// prepare for next instruction
m.scriptoff++
if m.scriptoff >= len(m.scripts[m.scriptidx]) {
// Illegal to have an `if' that straddles two scripts.
if err == nil && len(m.condStack) != 1 {
return false, StackErrMissingEndif
}
m.numOps = 0 // number of ops is per script.
m.scriptoff = 0
if m.scriptidx == 0 && m.bip16 {