Skip to content

Fix allocator mismatch ech knownhosts#21150

Closed
MarkLee131 wants to merge 4 commits intocurl:masterfrom
MarkLee131:fix-allocator-mismatch-ech-knownhosts
Closed

Fix allocator mismatch ech knownhosts#21150
MarkLee131 wants to merge 4 commits intocurl:masterfrom
MarkLee131:fix-allocator-mismatch-ech-knownhosts

Conversation

@MarkLee131
Copy link
Copy Markdown
Contributor

Fix #21149

memory allocated by libcurl (curl_maprintf) must be freed with
curl_free(), and memory allocated by the tool (curlx_strdup via
findfile) must be freed with curlx_free().

- tool_cfgable: ech_config is allocated with curl_maprintf, free it
  with curl_free() instead of tool_safefree()
- config2setopts: known hosts from findfile() is allocated with
  curlx_strdup, free it with curlx_free() instead of curl_free()
- tool_findfile: fix comment to say curlx_free() instead of curl_free()

Follow-up to b71973c
Copy link
Copy Markdown
Member

@bagder bagder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! It needs some minor adjustments though

For knownhosts, curlx_strdup() the findfile() result so that
config->knownhosts always uses tool-memory.

For ech_config, curlx_strdup() the curl_maprintf() result so that
config->ech_config always uses tool-memory, matching the getstr() path.
@MarkLee131
Copy link
Copy Markdown
Contributor Author

Thanks for the review.
Updated: now using curlx_strdup() on both the findfile() result for knownhosts and the curl_maprintf() result for ech_config, so both pointers consistently use tool-memory throughout. Also reverted the findfile() comment and tool_cfgable.c back to tool_safefree accordingly.

@bagder bagder closed this in 9fcc7e4 Mar 30, 2026
@bagder
Copy link
Copy Markdown
Member

bagder commented Mar 30, 2026

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

Two more allocator mismatches in the curl tool (same class as b71973c115)

2 participants