Fix a rare NullPointerException