From 3c8f9c92473fde2a6918b1b005f39f536c26feb4 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 4 Jan 2026 11:54:18 +0100 Subject: [PATCH] setopt: free the previous STRING_ENCODING before storing the new Follow-up to 6b9c75e219cdcfd3e17e7858 Fixes #20179 Reported-by: correctmost on github Closes #20180 --- lib/setopt.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/setopt.c b/lib/setopt.c index 06e7dd1b86..0c1da5bc12 100644 --- a/lib/setopt.c +++ b/lib/setopt.c @@ -1725,8 +1725,10 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option, */ if(ptr && !*ptr) { ptr = Curl_get_content_encodings(); - if(ptr) + if(ptr) { + curlx_free(s->str[STRING_ENCODING]); s->str[STRING_ENCODING] = ptr; + } else result = CURLE_OUT_OF_MEMORY; return result;