Skip to content

Potential Memory Leak Due to Missing CXPLAT_FREE() in Error Paths #5255

@t-minzheng

Description

@t-minzheng

Description
if either of the following calls failed:

if (QUIC_FAILED(Status = MsQuic->StreamOpen(Connection, QUIC_STREAM_OPEN_FLAG_UNIDIRECTIONAL, ServerStreamCallback, nullptr, &Stream))) {
printf("StreamOpen failed, 0x%x!\n", Status);
return;

if (QUIC_FAILED(Status = MsQuic->StreamStart(Stream, QUIC_STREAM_START_FLAG_NONE))) {
printf("StreamStart failed, 0x%x!\n", Status);
MsQuic->StreamClose(Stream);
return;
}

The allocated SendBuffer would not be freed, leading to a memory leak.

Suggested fix
Add CXPLAT_FREE(SendBuffer, QUIC_POOL_TOOL); in those paths. Ensure that for every CXPLAT_ALLOC there is a corresponding CXPLAT_FREE in all exit paths.

Metadata

Metadata

Labels

Area: TestingRelated to test coverageTriagedThis item has been triaged by an MsQuic ownerhelp wantedExtra attention is needed

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions