MFC	r270256:
Always check the limits of array index variables before using them.

Obtained from:	DragonFlyBSD