Fix potential NULL dereference found by scan