Couldn't fix it properly (by setting the flag as appropriate during a successful Flee attempt in combat), so I'm working around it and setting the flag to the only possible actual value it could be just prior to checking it where the error was being thrown.
Merge remote-tracking branch 'upstream/master'