Fix crash with malformed files
In Qt5 accessing a QByteArray index out of bounds returned 0, in Qt6 crashes/asserts, so check first and return 0 ourselves.
In an ideal world we would mark it as "something wrong happened", but we'll settle for not crashing now