Fix possible NPE due to #3658 change