Makes sure that indices are valid for given shape.
The shorter shape determines the length.
For instance,
>>> safe_indices( (3, 4, 5), (1, 6) ) (0, 5)