Avoid out-of-bounds access

Task-number: QTBUG-33364
Change-Id: I33d713df5d60a349c48f109a5f76db5fa57573af
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>