Fixes potential dereferencing of NULL.