CLI: Ensure IDs are non-zero

This fixes out-of-bounds accesses in several subcommands when the
invalid ID @0 is passed to the program.
This commit is contained in:
Janik Rabe 2018-08-06 14:06:04 +03:00 committed by lauft
parent 9489ed5b70
commit 48aa9cfdc0
2 changed files with 6 additions and 1 deletions

View file

@ -412,7 +412,8 @@ void CLI::identifyIds ()
int digits;
if (pig.skipLiteral ("@") &&
pig.getDigits (digits) &&
pig.eos ())
pig.eos () &&
digits > 0)
{
a.tag ("ID");
a.attribute ("value", digits);