Fix dereference before null check discovered by Coverity.