Fix a crash-by-unknown-exception caused by attempting to use a null pointer