tool_paramhlp: free the proto strings on exit

And also make sure that repeated use of the options free the previous
string before it stores a new.

Follow-up from e6f8445edef8e7996d

Closes #10098
This commit is contained in:
Daniel Stenberg 2022-12-14 23:55:37 +01:00
parent 24d494c264
commit 614f78131a
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
2 changed files with 3 additions and 0 deletions

View File

@ -90,6 +90,8 @@ static void free_config_fields(struct OperationConfig *config)
Curl_safefree(config->netrc_file);
Curl_safefree(config->output_dir);
Curl_safefree(config->proto_str);
Curl_safefree(config->proto_redir_str);
urlnode = config->url_list;
while(urlnode) {

View File

@ -433,6 +433,7 @@ ParameterError proto2num(struct OperationConfig *config,
result = curlx_dyn_addf(&obuf, "%s,", protoset[proto]);
free((char *) protoset);
curlx_dyn_setlen(&obuf, curlx_dyn_len(&obuf) - 1);
free(*ostr);
*ostr = curlx_dyn_ptr(&obuf);
return *ostr ? PARAM_OK : PARAM_NO_MEM;