Looking closer, I realized that my proposed change in RestoreGUCState is unnecessary, because guc_free() is already permissive about being passed a NULL. That leaves us with one live bug in get_explain_guc_options, two probably-unreachable hazards in check_GUC_init and write_one_nondefault_variable, and two API changes in GetConfigOption and GetConfigOptionResetString. I'm dubious that back-patching the API changes would be a good idea, so I applied that to HEAD only. The rest I backpatched as far as relevant.
Thanks for the report! regards, tom lane