Skip to content

curl_threads: don't do another malloc if the first fails - #20095

Closed
bagder wants to merge 1 commit into
masterfrom
bagder/threads-oom
Closed

curl_threads: don't do another malloc if the first fails#20095
bagder wants to merge 1 commit into
masterfrom
bagder/threads-oom

Conversation

@bagder

@bagder bagder commented Dec 25, 2025

Copy link
Copy Markdown
Member

No description provided.

@bagder
bagder marked this pull request as ready for review December 25, 2025 17:07
@bagder
bagder requested a review from Copilot December 25, 2025 17:07

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 optimizes error handling in the thread creation function by preventing an unnecessary memory allocation when the initial allocation fails. The change ensures that if the first curlx_malloc for the thread handle fails, the second curlx_malloc for the actual call structure is skipped entirely.

Key changes:

  • Initialize ac pointer to NULL instead of immediately allocating memory
  • Conditionally allocate ac only if the thread handle t was successfully allocated
  • Maintains existing error handling logic at the err label

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

@bagder bagder closed this in d4b62bf Dec 25, 2025
@bagder
bagder deleted the bagder/threads-oom branch December 25, 2025 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants