Does this prevent the crash for you? Can you explain what goes wrong and why you have to perform this check here?