Fix potential crash.

Change-Id: I03c86d2071ce612424bac9bf92a25208d0ba9443
Reviewed-by: Daniel Teske <daniel.teske@theqtcompany.com>