Apologies if you saw my earlier post and edits. I'm having fumble fingered problems.
See
these published interpretations for some guidance, and click on the 319.1 link.
If the marriage ends due to divorce or death of the USC spouse at any time before taking the oath, the naturalization is denied. You'd have to re-apply after you've had enough time as an LPR to apply without regard to the marriage.
If the divorce is started, but not finished, I'm not sure. I think that, as long as the marriage is still legally in place at the time the oath is given, you're OK.