fix possible NULL deref