Fix potential NPE in #822