]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
setopt: free the previous STRING_ENCODING before storing the new
authorDaniel Stenberg <daniel@haxx.se>
Sun, 4 Jan 2026 10:54:18 +0000 (11:54 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Sun, 4 Jan 2026 13:32:28 +0000 (14:32 +0100)
Follow-up to 6b9c75e219cdcfd3e17e7858

Fixes #20179
Reported-by: correctmost on github
Closes #20180

lib/setopt.c

index 06e7dd1b862bb63e33b4c2193118a60ea9666d6c..0c1da5bc120435633e6a55bbe24a176fa91d2cc0 100644 (file)
@@ -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;