Repository navigation
fix: prevent crash when writing to a closed wrap writer - #699
Merged
Merged
Conversation
Closing a WrapWriter returns its ANSI parser to a pool and clears the reference. When nested writer chains tear down out of order, a trailing style or link reset can be flushed back through a writer that was already closed, dereferencing a nil parser and crashing the program. Treat writes after close as a no-op so this teardown ordering is safe rather than fatal.
meowgorithm
approved these changes
Jun 12, 2026
eleboucher
pushed a commit
to eleboucher/apoci
that referenced
this pull request
Jun 12, 2026
This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | |---|---|---|---| | [charm.land/lipgloss/v2](https://github.com/charmbracelet/lipgloss) | `v2.0.3` β `v2.0.4` |  |  | --- ### Release Notes <details> <summary>charmbracelet/lipgloss (charm.land/lipgloss/v2)</summary> ### [`v2.0.4`](https://github.com/charmbracelet/lipgloss/releases/tag/v2.0.4) [Compare Source](charmbracelet/lipgloss@v2.0.3...v2.0.4) ### Mini Crash Patch Hi! This is a small patch to fix a writer-related panic. Thanks for using Lip Gloss! #### Changelog ##### Fixed - [`fefa41d`](charmbracelet/lipgloss@fefa41d): fix: prevent crash when writing to a closed wrap writer ([#​699](charmbracelet/lipgloss#699)) ([@​taciturnaxolotl](https://github.com/taciturnaxolotl)) ##### Docs - [`40ec0e6`](charmbracelet/lipgloss@40ec0e6): docs: fix typo in table comment ([#​641](charmbracelet/lipgloss#641)) ([@​aymanbagabas](https://github.com/aymanbagabas)) - [`a4d0b40`](charmbracelet/lipgloss@a4d0b40): docs: restore missing diaereses ([#​664](charmbracelet/lipgloss#664)) ([@​meowgorithm](https://github.com/meowgorithm)) ##### Chore - [`aa91b99`](charmbracelet/lipgloss@aa91b99): chore: remove CODEOWNERS ([@​aymanbagabas](https://github.com/aymanbagabas)) - [`9cbfe8b`](charmbracelet/lipgloss@9cbfe8b): chore(lint): exclude revive naming linter ([@​aymanbagabas](https://github.com/aymanbagabas)) *** <a href="https://charm.land/"><img alt="The Charm logo" src="https://stuff.charm.sh/charm-banner-next.jpg" width="400"></a> Thoughts? Questions? We love hearing from you. Feel free to reach out on [X](https://x.com/charmcli), [Discord](https://charm.land/discord), [Slack](https://charm.land/slack), [The Fediverse](https://mastodon.social/@​charmcli), [Bluesky](https://bsky.app/profile/charm.land). </details> --- ### Configuration π **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). π¦ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. β» **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. π **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xMDEuMSIsInVwZGF0ZWRJblZlciI6IjQzLjEwMS4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJ0eXBlL3BhdGNoIl19--> Reviewed-on: https://git.erwanleboucher.dev/eleboucher/apoci/pulls/78
dgalanberasaluce
pushed a commit
to dgalanberasaluce/maximus-cli
that referenced
this pull request
Jun 23, 2026
This PR contains the following updates: | Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) | |---|---|---|---| | [charm.land/lipgloss/v2](https://github.com/charmbracelet/lipgloss) | `v2.0.3` β `v2.0.4` |  |  | | [github.com/mattn/go-sqlite3](https://github.com/mattn/go-sqlite3) | `v1.14.45` β `v1.14.47` |  |  | --- ### Release Notes <details> <summary>charmbracelet/lipgloss (charm.land/lipgloss/v2)</summary> ### [`v2.0.4`](https://github.com/charmbracelet/lipgloss/releases/tag/v2.0.4) [Compare Source](charmbracelet/lipgloss@v2.0.3...v2.0.4) ### Mini Crash Patch Hi! This is a small patch to fix a writer-related panic. Thanks for using Lip Gloss! #### Changelog ##### Fixed - [`fefa41d`](charmbracelet/lipgloss@fefa41d): fix: prevent crash when writing to a closed wrap writer ([#​699](charmbracelet/lipgloss#699)) ([@​taciturnaxolotl](https://github.com/taciturnaxolotl)) ##### Docs - [`40ec0e6`](charmbracelet/lipgloss@40ec0e6): docs: fix typo in table comment ([#​641](charmbracelet/lipgloss#641)) ([@​aymanbagabas](https://github.com/aymanbagabas)) - [`a4d0b40`](charmbracelet/lipgloss@a4d0b40): docs: restore missing diaereses ([#​664](charmbracelet/lipgloss#664)) ([@​meowgorithm](https://github.com/meowgorithm)) ##### Chore - [`aa91b99`](charmbracelet/lipgloss@aa91b99): chore: remove CODEOWNERS ([@​aymanbagabas](https://github.com/aymanbagabas)) - [`9cbfe8b`](charmbracelet/lipgloss@9cbfe8b): chore(lint): exclude revive naming linter ([@​aymanbagabas](https://github.com/aymanbagabas)) *** <a href="https://charm.land/"><img alt="The Charm logo" src="https://stuff.charm.sh/charm-banner-next.jpg" width="400"></a> Thoughts? Questions? We love hearing from you. Feel free to reach out on [X](https://x.com/charmcli), [Discord](https://charm.land/discord), [Slack](https://charm.land/slack), [The Fediverse](https://mastodon.social/@​charmcli), [Bluesky](https://bsky.app/profile/charm.land). </details> <details> <summary>mattn/go-sqlite3 (github.com/mattn/go-sqlite3)</summary> ### [`v1.14.47`](mattn/go-sqlite3@v1.14.46...v1.14.47) [Compare Source](mattn/go-sqlite3@v1.14.46...v1.14.47) ### [`v1.14.46`](mattn/go-sqlite3@v1.14.45...v1.14.46) [Compare Source](mattn/go-sqlite3@v1.14.45...v1.14.46) </details> --- ### Configuration π **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). π¦ **Automerge**: Disabled by config. Please merge this manually once you are satisfied. β» **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. π» **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://github.com/renovatebot/renovate/discussions) if that's undesired. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My43My4yIiwidXBkYXRlZEluVmVyIjoiNDMuNzMuMiIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==--> Reviewed-on: https://forgejo.internal/forgejo_admin/maximus/pulls/16 Co-authored-by: Renovate Bot <renovatebot@forgejo.internal> Co-committed-by: Renovate Bot <renovatebot@forgejo.internal>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A
WrapWriterpanics with a nil pointer dereference if it is written to after being closed.Close()returns the internal ANSI parser to async.Pooland nils the reference, butWritedereferenced it unconditionally.This surfaces when nested writer chains tear down out of order: closing an outer writer can flush a trailing style or link reset back through a writer that was already closed, crashing the program. Glamour's block rendering hits this when a styled run is left open across an indent or margin boundary (common when rendering partial/streamed markdown).
Fix
Treat a write after close as a safe no-op rather than a fatal panic. A closed writer has nothing useful to do with further bytes, so swallowing them keeps out-of-order teardown safe.
Test
TestWrapWriterWriteAfterClosewrites after close and asserts no panic. It fails (nil pointer dereference) without the guard and passes with it.π Generated with Crush