Fix array overrun in palette loader

As the EOF was not checked after the fread, it would always write one
extra palette index than was allocated.