Add the missing check for NULL pointer before use it.