fdo#77806: Check the boundaries before accessing an array....

Change-Id: I0878f734599f566cde83183947cd7613c0f8d5c6
(cherry picked from commit a45973a90625f4b9e0f603154194f357ff2418d4)
Reviewed-on: https://gerrit.libreoffice.org/9292
Tested-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>