Skip to content

tool_operate: fix memory-leak on failed uploads - #21062

Closed
bagder wants to merge 2 commits into
masterfrom
bagder/tool-cleanups
Closed

bagder wants to merge 2 commits into
masterfrom
bagder/tool-cleanups

Conversation

@bagder

@bagder bagder commented Mar 22, 2026

Copy link
Copy Markdown
Member

Add test case 1673 to do repeated upload failures and verify there is no leak.

Reported-by: James Fuller

Add test case 1673 to do repeated upload failures and verify there
is no leak.

Reported-by: James Fuller
@github-actions github-actions Bot added the tests label Mar 22, 2026
@bagder
bagder marked this pull request as ready for review March 22, 2026 16:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to fix a memory leak in the curl tool when uploads fail (especially under retry scenarios), and adds a regression test intended to catch the leak.

Changes:

  • Centralize per_transfer resource cleanup in del_per_transfer() (including per->curl, per->url, per->outfile, per->uploadfile).
  • Remove now-redundant per-transfer cleanup from post_per_transfer().
  • Add test case 1673 and register it in the test data Makefile.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/tool_operate.c Moves easy-handle and per-transfer string frees into del_per_transfer() to avoid leaks when transfers are deleted without full post-cleanup.
tests/data/test1673 Adds a new test intended to exercise repeated upload failures with --retry.
tests/data/Makefile.am Registers test1673 in the testcases list.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tests/data/test1673 Resolved
Comment thread tests/data/test1673 Resolved
@bagder bagder closed this in 9820e5d Mar 22, 2026
@bagder
bagder deleted the bagder/tool-cleanups branch March 22, 2026 22:58
outcast36 pushed a commit to greearb/curl that referenced this pull request Jun 3, 2026
Add test case 1673 to do repeated upload failures and verify there is no
leak. This proved a previous leak and now it verifies the fix.

Reported-by: James Fuller
Closes curl#21062
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.

2 participants