Fix some Clang static analysis warnings about null pointers.