]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
cf-h2-prox: fix peer leak
authorStefan Eissing <stefan@eissing.org>
Fri, 15 May 2026 11:37:36 +0000 (13:37 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Sat, 16 May 2026 22:14:36 +0000 (00:14 +0200)
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

lib/cf-h2-proxy.c

index 1dfd0a0a46034b47ce0b121d12130aa45d941e3a..297afb3c8cb15f542c81d3012ecd274cfbb57127 100644 (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);
   }
 }