Add a boundary check, avoiding access past actual data.
Ideally would need to report error to the user somehow,
but it doesn't seem to be easy to do.
Not sure if it is safe enough for 2.92. It is an old bug,
so might play save and only apply for 2.93?