TextBuffer::ResizeTraditional may leak stale pointers #19231

Open
opened 2026-01-31 06:37:34 +00:00 by claunia · 0 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.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#19231