> However, for Postgres 15 this may can cause a small memory leak.
What memory leak? There's no leak here.
Yeah, as per Julien's answer, there is really no memory leak, but just unnecessary double execution of pstrdup. But for Postgres 15, I believe it's worth avoiding this, because it's wasted cycles. For Postgres 16, I believe this will be fixed as well, but for robustness, better fix soon, IMO.