Fixed a null-dereference bug