Cap splice's index parameter to length

When the index parameter of a splice is beyond its length then the
length should be taken as the index.