Prevent some crashes caused by array index being out of bounds
Prevent some crashes caused by array index being out of bounds

Reviewed-by: David Edmundson

leonhandreke/ktp-common-internals,KDE/ktp-common-internals,leonhandreke/ktp-common-internals,leonhandreke/ktp-common-internals,KDE/ktp-common-internals,KDE/ktp-common-internals