sspi: fix memory leaks on error paths in Curl_create_sspi_identity() - #19866
Closed
vszakats wants to merge 2 commits into
Closed
sspi: fix memory leaks on error paths in Curl_create_sspi_identity()#19866vszakats wants to merge 2 commits into
Curl_create_sspi_identity()#19866vszakats wants to merge 2 commits into
Conversation
** MEMORY FAILURE Leak detected: memory still allocated: 20 bytes At 1a1e8136328, there is 18 bytes. allocated by D:/a/curl/curl/lib/curl_sspi.c:133 At 1a1e8139368, there is 2 bytes. allocated by D:/a/curl/curl/lib/curl_sspi.c:143 1072: torture FAILED: function number 207 in test. invoke with "-t207" to repeat this single case. Warning: http2 server unexpectedly alive https://github.com/curl/curl/actions/runs/20008523913/job/57374427439?pr=19865
2 tasks
There was a problem hiding this comment.
Pull request overview
This PR fixes memory leaks in the SSPI authentication code that were detected during Windows torture testing. The leaks occurred when error conditions were encountered after successful memory allocations, but before the function could complete.
Key Changes:
- Added missing
curlx_free()calls fordup_useranddup_domainon all error paths after they are allocated - Moved identity structure assignments to the end of the function, after all error paths, simplifying the code and ensuring proper cleanup on failures
- Ensures all allocated resources are properly freed before returning error codes
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Curl_create_sspi_identity()
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.
Detected by Windows torture test 1072 (with
-shallow=20/13),test 579 (with
-shallow=18/14/13), and test 1286 (with-shallow=15).Ref: https://github.com/curl/curl/actions/runs/20008523913/job/57374427439?pr=19865
Also simplify the code a little.
Cherry-picked from #19865