TextBuffer::ResizeTraditional may leak stale pointers #19234

Closed
opened 2026-01-31 06:37:37 +00:00 by claunia · 2 comments
Owner

Originally created by @lhecker on GitHub (Jan 18, 2023).

Originally assigned to: @lhecker on GitHub.

The catch clause will allow BufferAllocator to be destroyed while the ROWs in _storage continue to reference its memory. The solution is to refactor ROW::Resize from being a mutating function over to allocating a new _storage vector and copying all rows over. That way the TextBuffer is only mutated once at the end, long after all throwing code has finished executing.

Originally created by @lhecker on GitHub (Jan 18, 2023). Originally assigned to: @lhecker on GitHub. The catch clause will allow `BufferAllocator` to be destroyed while the `ROW`s in `_storage` continue to reference its memory. The solution is to refactor `ROW::Resize` from being a mutating function over to allocating a new `_storage` vector and copying all rows over. That way the `TextBuffer` is only mutated once at the end, long after all throwing code has finished executing.
Author
Owner

@zadjii-msft commented on GitHub (Apr 4, 2023):

@lhecker was this closed in #15105?

@zadjii-msft commented on GitHub (Apr 4, 2023): @lhecker was this closed in #15105?
Author
Owner

@lhecker commented on GitHub (Apr 4, 2023):

Oh, yes, thank you!

@lhecker commented on GitHub (Apr 4, 2023): Oh, yes, thank you!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#19234