fix(forwarder): null-check allocations and fix resource leaks in quicforward#5807
Merged
guhetier merged 5 commits intomicrosoft:mainfrom Mar 4, 2026
Merged
Conversation
…forward - Check MsQuicStream allocs in ConnectionCallback; close raw stream handle on failure instead of leaking it - Check MsQuicConnection allocs in ListenerCallback; return QUIC_STATUS_OUT_OF_MEMORY so MsQuic refuses connection cleanly - Free SendContext before CXPLAT_FRE_ASSERT fires on unexpected send errors in StreamCallback
guhetier
reviewed
Feb 23, 2026
guhetier
reviewed
Feb 24, 2026
…for CleanUpAutoDelete objects
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5807 +/- ##
==========================================
+ Coverage 85.04% 85.67% +0.63%
==========================================
Files 60 60
Lines 18729 18729
==========================================
+ Hits 15928 16046 +118
+ Misses 2801 2683 -118 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
guhetier
reviewed
Mar 2, 2026
guhetier
reviewed
Mar 2, 2026
Collaborator
guhetier
left a comment
There was a problem hiding this comment.
Looks good to me, except some nit style.
Add braces Co-authored-by: Guillaume Hetier <hetier.guillaume@gmail.com>
Contributor
Author
Done. Thank you! |
guhetier
reviewed
Mar 2, 2026
guhetier
approved these changes
Mar 3, 2026
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.
Description
Fixes #5806.
In quicforward.cpp, MsQuicStream and MsQuicConnection objects are allocated with new(std::nothrow) in ConnectionCallback and ListenerCallback, but the results are never null-checked before being dereferenced. Under OOM conditions this causes a null pointer dereference and crash. The correct guard pattern already exists in MsQuicAutoAcceptListener in msquic.hpp and is applied here consistently.
Ownership notes:
Confirmed via listener.c that failure returns are permitted — MsQuic
refuses the connection and retains handle ownership, so no manual cleanup
of the raw connection handle is needed.
failure, matching the pattern in spinquic.cpp. Sequential allocation is
intentional — MsQuicConnection's constructor calls SetCallbackHandler
immediately, so a consolidated null-check would risk closing a handle
not yet owned by the caller.
Testing
No existing tests cover these OOM paths. Built successfully on Linux (GitHub Codespaces) and validated normal forwarding behavior is unaffected. Reliably triggering these paths requires fault injection that does not currently exist for this code. Happy to add coverage if maintainers have a preferred approach.
Documentation
None.