Skip to content

Add null checks for CXPLAT_ALLOC_NONPAGED and CxPlatPoolAlloc calls#5326

Open
guhetier with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-5233
Open

Add null checks for CXPLAT_ALLOC_NONPAGED and CxPlatPoolAlloc calls#5326
guhetier with Copilot wants to merge 2 commits into
mainfrom
copilot/fix-5233

Conversation

Copilot AI commented Aug 5, 2025

Copy link
Copy Markdown
Contributor

This PR addresses missing null pointer checks for memory allocation functions CXPLAT_ALLOC_NONPAGED and CxPlatPoolAlloc in several locations throughout the codebase. Without these checks, allocation failures could lead to null pointer dereferences and undefined behavior.

Changes Made

src/perf/lib/Tcp.cpp

  • Added null check for LocalTP allocation in InitializeTls() function
  • Returns false with error message if allocation fails

src/core/unittest/RecvBufferTest.cpp

  • Added null check for PreallocChunk allocation with proper QUIC_STATUS_OUT_OF_MEMORY return
  • Added null check for AppOwnedBuffer allocation with proper error handling
  • Added null checks for both CxPlatPoolAlloc calls with comprehensive resource cleanup to prevent memory leaks

src/platform/unittest/TlsTest.cpp

  • Added null check for session ticket buffer allocation in OnSessionTicketReceived()
  • Returns FALSE on allocation failure

Implementation Details

All changes follow existing error handling patterns found in the codebase:

  • Use of QUIC_STATUS_OUT_OF_MEMORY for functions returning QUIC_STATUS
  • Boolean false returns for functions with boolean return types
  • Proper cleanup of previously allocated resources on subsequent allocation failures
  • Consistent error messaging and logging

The implementation is minimal and surgical, adding only the necessary null checks without modifying existing functionality. All existing tests continue to pass, ensuring no regressions were introduced.

Fixes #5233.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI changed the title [WIP] Miss check for the return value of CXPLAT_ALLOC_NONPAGED and CxPlatPoolAlloc Add null checks for CXPLAT_ALLOC_NONPAGED and CxPlatPoolAlloc calls Aug 5, 2025
Copilot AI requested a review from guhetier August 5, 2025 00:38
@guhetier guhetier marked this pull request as ready for review October 2, 2025 16:21
@guhetier guhetier requested a review from a team as a code owner October 2, 2025 16:21
@ProjectsByJackHe

Copy link
Copy Markdown
Contributor

Do you want to abandon this PR or does this need a review still? The NULL checks LGTM but your call @guhetier

Copilot AI and others added 2 commits July 14, 2026 12:56
Co-authored-by: guhetier <15261469+guhetier@users.noreply.github.com>
@guhetier guhetier enabled auto-merge (squash) July 14, 2026 20:07
@guhetier

Copy link
Copy Markdown
Collaborator

That one got buried under higher priority fixes, but it is ready. I rebased it if you can re-approve.

@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.01%. Comparing base (d597675) to head (f6cc9b4).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5326      +/-   ##
==========================================
- Coverage   85.36%   85.01%   -0.35%     
==========================================
  Files          60       60              
  Lines       18973    18973              
==========================================
- Hits        16196    16130      -66     
- Misses       2777     2843      +66     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Miss check for the return value of CXPLAT_ALLOC_NONPAGED and CxPlatPoolAlloc

3 participants