Fix a crash in the span going beyond the end