[PR #12340] [MERGED] Fix a memory leak in onecore interactivity #28995

Open
opened 2026-01-31 09:32:09 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/12340
Author: @zadjii-msft
Created: 2/3/2022
Status: ✅ Merged
Merged: 2/15/2022
Merged by: @undefined

Base: main ← Head: dev/migrie/b/6759-this-doesnt-even-build-in-oss


📝 Commits (1)

  • aa93222 Fix a memory leak in onecore interactivity

📊 Changes

1 file changed (+1 additions, -9 deletions)

View changed files

📝 src/interactivity/onecore/ConIoSrvComm.cpp (+1 -9)

📄 Description

As noted in #6759:

RtlCreateUnicodeString creates a copy of the string on the process heap and the PortName variable has local-scope. The string doesn't get freed with RtlFreeUnicodeString before the function returns creating a memory leak.
CIS_ALPC_PORT_NAME is a constant string and the PortName variable should instead be initialized using the RTL_CONSTANT_STRING macro:

static UNICODE_STRING PortName = RTL_CONSTANT_STRING(CIS_ALPC_PORT_NAME);

I actually built this in the OS repo to make sure it'll still build, because this code doesn't even build outside Windows.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/12340 **Author:** [@zadjii-msft](https://github.com/zadjii-msft) **Created:** 2/3/2022 **Status:** ✅ Merged **Merged:** 2/15/2022 **Merged by:** [@undefined](undefined) **Base:** `main` ← **Head:** `dev/migrie/b/6759-this-doesnt-even-build-in-oss` --- ### 📝 Commits (1) - [`aa93222`](https://github.com/microsoft/terminal/commit/aa932220c599d6ea6f3113636730a3f0aa03e4d0) Fix a memory leak in onecore interactivity ### 📊 Changes **1 file changed** (+1 additions, -9 deletions) <details> <summary>View changed files</summary> 📝 `src/interactivity/onecore/ConIoSrvComm.cpp` (+1 -9) </details> ### 📄 Description As noted in #6759: > `RtlCreateUnicodeString` creates a copy of the string on the process heap and the `PortName` variable has local-scope. The string doesn't get freed with `RtlFreeUnicodeString` before the function returns creating a memory leak. > `CIS_ALPC_PORT_NAME` is a constant string and the `PortName` variable should instead be initialized using the `RTL_CONSTANT_STRING` macro: > > ```c++ > static UNICODE_STRING PortName = RTL_CONSTANT_STRING(CIS_ALPC_PORT_NAME); > ``` I actually built this in the OS repo to make sure it'll still build, because this code doesn't even build outside Windows. * [x] Closes #6759 * I work here. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:32:09 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#28995