Skip to content

Conversation

@jserv
Copy link
Contributor

@jserv jserv commented Jan 11, 2026

This extracts shared toggle logic from iui_checkbox() and iui_radio() into helper functions, reducing code duplication.

It also fixes dropdown index clamping bug where clamped value was not synced back to user's selected_index pointer.


Summary by cubic

Consolidated checkbox and radio into a shared toggle helper for consistent behavior and less duplication. Fixed dropdown clamping to correctly update selected_index.

  • Refactors

    • Added a toggle_base helper with draw callbacks used by checkbox and radio.
    • Unified focus ring, pointer press, and Enter key handling across toggles.
  • Bug Fixes

    • When clamping dropdown indices, the clamped value is now written back to options->selected_index to prevent desync.

Written for commit a6eba4a. Summary will update on new commits.

Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="src/input.c">

<violation number="1" location="src/input.c:1212">
P1: Type confusion vulnerability: toggle_base() uses `radio_value >= 0` to distinguish between int* and bool* pointers. If iui_radio() receives a negative button_value, the function will treat the int* as bool*, causing memory corruption. Either validate button_value >= 0 in iui_radio(), or use a separate boolean parameter to distinguish radio/checkbox modes instead of relying on radio_value's sign.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

This extracts shared toggle logic from iui_checkbox() and iui_radio()
into helper functions, reducing code duplication.

It also fixes dropdown index clamping bug where clamped value was not
synced back to user's selected_index pointer.
@jserv jserv merged commit 73ea660 into main Jan 11, 2026
11 checks passed
@jserv jserv deleted the toggle-widget branch January 11, 2026 17:55
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.

2 participants