bidi: Be safer against bad input
Don't run off the end of an array that we allocated to certain length. Closes: #342
Is there any ways to reproduce that in old versions of pango, such as: 1.40.14 or 1.38.1. I saw that those version has not the loop for part, but I'm not sure if they can be affected since I could not find the issue session or the bug report with any reproduction step.
Linked issue report is now unembargoed.