[PR #10878] [MERGED] Fix a use-after-free crash when returning from the alt buffer #28276

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/10878
Author: @j4james
Created: 8/5/2021
Status: Merged
Merged: 8/5/2021
Merged by: @undefined

Base: mainHead: fix-altbuffer-crash


📝 Commits (1)

  • 073132a Don't access the alt buffer after it has been deleted.

📊 Changes

1 file changed (+3 additions, -2 deletions)

View changed files

📝 src/host/screenInfo.cpp (+3 -2)

📄 Description

Summary of the Pull Request

When switching from the alt buffer back to the main buffer, we need to copy certain cursor attributes from the one to the other. However, this copying was taking place after the alt buffer had been freed, and thus could result in the app crashing. This PR simply moves that code up a bit so it's prior to the buffer being freed.

References

PR #10843 added the code that introduced this problem.

PR Checklist

  • Closes #xxx
  • CLA signed.
  • Tests added/passed
  • Documentation updated.
  • Schema updated.
  • I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx

Validation Steps Performed

I was able to reproduce the crash when using a debug build, and confirmed that the crash no longer occurred after this PR was applied. I also checked that the cursor attributes were still being correctly copied back when returning from the alt buffer.


🔄 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/10878 **Author:** [@j4james](https://github.com/j4james) **Created:** 8/5/2021 **Status:** ✅ Merged **Merged:** 8/5/2021 **Merged by:** [@undefined](undefined) **Base:** `main` ← **Head:** `fix-altbuffer-crash` --- ### 📝 Commits (1) - [`073132a`](https://github.com/microsoft/terminal/commit/073132a8bd7e7ea0cc9131569ce709a748e6446a) Don't access the alt buffer after it has been deleted. ### 📊 Changes **1 file changed** (+3 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src/host/screenInfo.cpp` (+3 -2) </details> ### 📄 Description ## Summary of the Pull Request When switching from the alt buffer back to the main buffer, we need to copy certain cursor attributes from the one to the other. However, this copying was taking place after the alt buffer had been freed, and thus could result in the app crashing. This PR simply moves that code up a bit so it's prior to the buffer being freed. ## References PR #10843 added the code that introduced this problem. ## PR Checklist * [ ] Closes #xxx * [x] CLA signed. * [ ] Tests added/passed * [ ] Documentation updated. * [ ] Schema updated. * [ ] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx ## Validation Steps Performed I was able to reproduce the crash when using a debug build, and confirmed that the crash no longer occurred after this PR was applied. I also checked that the cursor attributes were still being correctly copied back when returning from the alt buffer. --- <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:27:27 +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#28276