secp256k1_musig_partial_sign loads the two secret nonce scalars and then zeroes the secnonce, so the stack copies are the only ones left. Five ARG_CHECKs follow: four on NULL arguments and one, after the secret key is loaded, on the secnonce's public key matching the keypair. ARG_CHECK returns directly, so these exits skip secp256k1_musig_partial_sign_clear, which every other exit after the load calls.
This moves the four NULL checks before the secnonce is loaded, so a call with a NULL argument now leaves the secnonce untouched. The key-match check needs both the secnonce and the keypair loaded, so it stays in place and the nonces and the secret key are cleared before it fails. The checks and their messages are unchanged.
It matters only when the illegal callback returns and the API is misused, the key mismatch being the realistic case. It does for these exits what #1849 did for secp256k1_musig_nonce_gen_counter.
Assisted-by: my usual tools (LLM, Internet, computer). Mistakes are mine.