Fixed crashs on garbage code (#5604)