UltraRogue: add a sanity check to do_fuses().

The d_id field, which indicates which fuse function to call, is now
checked to make sure it is not out of range.  do_daemons() already
checks.
This commit is contained in:
John "Elwin" Edwards 2017-11-24 16:22:10 -05:00
parent 1e2f3f5803
commit 5e60293223

View file

@ -282,11 +282,18 @@ do_fuses(int now)
{ {
if (--wire->d_time <= 0) if (--wire->d_time <= 0)
{ {
fuse_arg arg; if (wire->d_id < 0 || wire->d_id >= FUSE_MAX)
printf("Bad fuse id %d\n", wire->d_id);
else if (fuses[wire->d_id].func == NULL)
printf("No action for fuse %d!\n", wire->d_id);
else
{
fuse_arg arg;
arg.varg = wire->d_arg; arg.varg = wire->d_arg;
fuses[wire->d_id].func(&arg);
}
wire->d_type = EMPTY; wire->d_type = EMPTY;
fuses[wire->d_id].func(&arg);
demoncnt -= 1; demoncnt -= 1;
} }
} }