The stability of localized corrosion