Bad ordering of error check