cherry-pick: fix NPE