[PR #640] [MERGED] fix(buffer): add errdefer for allocations in OptimizedBuffer init #1457

Closed
opened 2026-03-14 09:37:55 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/anomalyco/opentui/pull/640
Author: @simonklee
Created: 2/7/2026
Status: Merged
Merged: 2/7/2026
Merged by: @kommander

Base: mainHead: buffer-alloc


📝 Commits (1)

  • 38c25f0 fix(buffer): add errdefer for allocations in OptimizedBuffer init

📊 Changes

2 files changed (+35 additions, -4 deletions)

View changed files

📝 packages/core/src/zig/buffer.zig (+15 -4)
📝 packages/core/src/zig/tests/buffer_test.zig (+20 -0)

📄 Description

Pre-allocate buffers before struct assignment so errdefer can free them on partial failure.

Prev, when one of the later allocations failed with OOM, earlier successful allocations were not released before returning, so if the caller retried it it would leak.


🔄 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/anomalyco/opentui/pull/640 **Author:** [@simonklee](https://github.com/simonklee) **Created:** 2/7/2026 **Status:** ✅ Merged **Merged:** 2/7/2026 **Merged by:** [@kommander](https://github.com/kommander) **Base:** `main` ← **Head:** `buffer-alloc` --- ### 📝 Commits (1) - [`38c25f0`](https://github.com/anomalyco/opentui/commit/38c25f08295f1166887aaf49a927af6bcffbf022) fix(buffer): add errdefer for allocations in OptimizedBuffer init ### 📊 Changes **2 files changed** (+35 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `packages/core/src/zig/buffer.zig` (+15 -4) 📝 `packages/core/src/zig/tests/buffer_test.zig` (+20 -0) </details> ### 📄 Description Pre-allocate buffers before struct assignment so errdefer can free them on partial failure. Prev, when one of the later allocations failed with OOM, earlier successful allocations were not released before returning, so if the caller retried it it would leak. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-14 09:37:55 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/opentui#1457
No description provided.