Add sanity check to avoid segfault.