Skip to content

fix: prevent integer divide by zero panic in AutoMerge table rendering - #430

Closed
AdamMagued wants to merge 1 commit into
jedib0t:mainfrom
AdamMagued:fix-automerge-zero-columns-panic
Closed

AdamMagued wants to merge 1 commit into
jedib0t:mainfrom
AdamMagued:fix-automerge-zero-columns-panic

Conversation

@AdamMagued

Copy link
Copy Markdown

When rendering a table configured with AutoMerge and empty/zero visible columns or when columns are suppressed, reBalanceMaxMergedColumnLengths previously divided by numMergedColumns or columnsRemaining without checking for zero, causing an integer divide by zero runtime panic.

Guard rebalancing by returning early when numColumns or maxColumnLengths is empty, and verify divisor positive bounds. Add regression tests in TestTable_Render_AutoMerge_EdgeCases.

Fixes #426

When rendering a table configured with AutoMerge and empty/zero visible columns or when columns are suppressed, reBalanceMaxMergedColumnLengths previously divided by numMergedColumns or columnsRemaining without checking for zero, causing an integer divide by zero runtime panic.

Guard rebalancing by returning early when numColumns or maxColumnLengths is empty, and verify divisor positive bounds. Add regression tests in TestTable_Render_AutoMerge_EdgeCases.

Fixes jedib0t#426
@sonarqubecloud

sonarqubecloud Bot commented Oct 2, 2026

Copy link
Copy Markdown

@AdamMagued

Copy link
Copy Markdown
Author

Closing in favor of earlier community PR #427 to keep the review queue clean.

@AdamMagued AdamMagued closed this Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Render panics with integer divide by zero when an AutoMerge cell is wider than its columns

1 participant