core: fix nullptr deref