Added checks for the array index code in hid.c.