8000 Add null checks for CXPLAT_ALLOC_NONPAGED and CxPlatPoolAlloc calls by Copilot · Pull Request #5326 · microsoft/msquic · GitHub
[go: up one dir, main page]

Skip to content

Conversation

Copy link
Contributor
Copilot AI commented Aug 5, 2025

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.

Co-authored-by: guhetier <15261469+guhetier@users.noreply.github.com>
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
Copilot finished work on behalf of 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
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

2 participants

0