fix null deref crashes