Fixed crash on invalid code (#5603)