setopt: free the previous STRING_ENCODING before storing the new

Follow-up to 6b9c75e219

Fixes #20179
Reported-by: correctmost on github
Closes #20180
This commit is contained in:
Daniel Stenberg 2026-01-04 11:54:18 +01:00
parent eb7f5b71e5
commit 3c8f9c9247
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View 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;