kohler/click — pull request #69 by trackpick (2012-11-07 18:36:43+00:00)
Title: classification.hh: fix bug when matching with an empty program

Any Classifier whose first argument is '-' or '0/??' (or similar I guess) aborts
with:
vector.hh:288: T& Vector::operator[](int) [with T =
Classification::Wordwise::Insn]: Assertion `(unsigned) i < (unsigned) vm_.n_'
failed.

Classifier-02.testie demonstrates the bug.

I think what's going on is that the resulting Program is empty for such cases,
but match() nevertheless tries to initialize a variable with the first
instruction in the Program. This change just moves the variable declaration and
initialisation to where we know the Program isn't empty, namely the point where
match() would have returned on _output_everything >= 0 for an empty Program.

Cliff Frey reviewed this and made a correction to my initial fix.

Signed-off-by: Patrick Verkaik