Fixed a potential crash issue for portal