I think the one case where this logic might not work perfectly is in the case where the SMTP password was intentionally cleared to be empty, the user is editing their composite/incoming password, and backspaces all the way/clears it with X because they think they made a typo.  This will re-capture the SMTP password field.

I mention this mainly just to prove I looked at this logic.  I would not change this logic at all because that's a crazy use case and trying to support it is much more likely to break everything.