Avoid out-of-bounds access

Task-number: QTBUG-33364
Change-Id: I33d713df5d60a349c48f109a5f76db5fa57573af
Reviewed-by: Laszlo Agocs <laszlo.agocs@digia.com>
Merge remote-tracking branch 'origin/stable' into dev

Change-Id: Id90bd6d65f15785215cdac2c19bae937925afbd3