Skip to content

Panic on huge -width: makeslice len out of range in side-by-side rendering #100

@peczenyj

Description

@peczenyj

Symptom

structalign -diff=side -width=4611686018427387904 ./_example
panic: runtime error: makeslice: len out of range

A user-supplied -width propagates unclamped into internal/ui:

  • truncPadrunewidth.FillRight(s, w) tries to allocate w bytes
  • renderSideBySide's divider → strings.Repeat("─", p.Width) likewise

Origin

Found by the ClusterFuzzLite integration work (#99): fuzz_trunc_pad crashed within 5 seconds in the OSS-Fuzz container. The bug is pre-existing — the pre-#94 hand-rolled loop had the identical strings.Repeat(" ", w-total) panic.

Fix

Clamp the column width to a sane maximum (far wider than any terminal) in truncPad (totality of the fuzzed contract) and in renderSideBySide (covers the divider). Regression test included.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions