Repository navigation
Free the curl handle when setup fails for InputStream responses in the native curl backend - #3092
Merged
Merged
Conversation
If request setup threw before a handler took over the curl handle, the handle and the response buffers were never freed. Setup failures in send, handleBase, handleFile and handleBaseWithMulti now free them.
adamw
force-pushed
the
fix-curl-handle-leak-on-send
branch
from
December 3, 2026 09:59
a43f400 to
418fead
Compare
Setup in send can't throw, and handleBase and handleFile already free the handle through ensure. Only handleBaseWithMulti leaked: when the request body or curl_multi_add_handle failed, nothing freed the handles and buffers.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In the Scala Native curl backend, requests with an
InputStreamresponse leaked the curl handle and the response buffers when request setup failed. This happened when the request body couldn't be read (e.g. a missing file, anInputStreambody that throws, or a stream body, which curl doesn't support), or whencurl_multi_add_handlefailed.handleBaseWithMultinow frees the handles and buffers on these failures and returns the error. The other paths already freed them.No test: the leak is native memory only, and a test can't see it without test-only hooks in production code.