Skip to content

fix: assert n_ticks >= 2 when SetupAxisTicks gets custom labels - #205

Merged
brenocq merged 1 commit into
mainfrom
fix/setup-axis-ticks-labels-overflow
Oct 25, 2026
Merged

brenocq merged 1 commit into
mainfrom
fix/setup-axis-ticks-labels-overflow

Conversation

@brenocq

@brenocq brenocq commented Oct 25, 2026

Copy link
Copy Markdown
Owner

Calling SetupAxisTicks(axis, v_min, v_max, 1, labels) with a one-element labels array read past the end of the array. The range overload quietly raises n_ticks to 2 and then reads labels[1], so the second tick label is garbage or a crash (AddressSanitizer reports a stack-buffer-overflow).

It now asserts that n_ticks is at least 2 when custom labels are given, so the mistake is reported instead of reading out of bounds. Calls without labels still clamp to 2 as before. Mirrors epezent/implot#677.

SetupAxisTicks(idx, v_min, v_max, n_ticks, labels) silently raised n_ticks to 2 and then read labels[1], past the end of a caller's array that had a single label. With custom labels it now asserts that n_ticks is at least 2.

Mirrors epezent/implot#677.
@brenocq brenocq added type:fix Something isn't working prio:medium Medium priority status:review The task is under review labels Oct 25, 2026
@brenocq brenocq self-assigned this Oct 25, 2026
@brenocq
brenocq merged commit 8687856 into main Oct 25, 2026
10 checks passed
@brenocq
brenocq deleted the fix/setup-axis-ticks-labels-overflow branch October 25, 2026 14:34
@github-actions github-actions Bot added status:done Task completed successfully and removed status:review The task is under review labels Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

prio:medium Medium priority status:done Task completed successfully type:fix Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant