cf-h2-prox: fix peer leak

The unlinking of the new Curl_peer was happening too later after
the struct had been set to zero. Move the unlink to happen before
that.

Fixes #21602
Reported-by: Joshua Rogers
Closes #21627
This commit is contained in:
Stefan Eissing 2026-05-15 13:37:36 +02:00 committed by Daniel Stenberg
parent 061136f24b
commit a0f08d6975
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2

View file

@ -190,6 +190,7 @@ static void cf_h2_proxy_ctx_clear(struct cf_h2_proxy_ctx *ctx)
}
Curl_bufq_free(&ctx->inbufq);
Curl_bufq_free(&ctx->outbufq);
Curl_peer_unlink(&ctx->dest);
tunnel_stream_clear(&ctx->tunnel);
memset(ctx, 0, sizeof(*ctx));
ctx->call_data = save;
@ -199,7 +200,6 @@ static void cf_h2_proxy_ctx_free(struct cf_h2_proxy_ctx *ctx)
{
if(ctx) {
cf_h2_proxy_ctx_clear(ctx);
Curl_peer_unlink(&ctx->dest);
curlx_free(ctx);
}
}