ui: fix potential null pointer