so what happens? they invalidate the election and have a new one?
If a judge is convinced the illegality is large enough to throw the results into question.
Whatever the judge wants to happen. Assuming the number of illgal ballots is greater than the margin of victory, the outcome is legitimately in question. At that point, if the judge decides he wants the election to go to Cochran, then the election results stand on whatever rationale the judge cooks up.
Law is an outcome driven process. There are enough precedents out there that any court decision can go either way. Judges pick the outcome, then write the opinion.