Fix potential NULL deref