[Bugfix] Color component values outside 0-255 wrap silently without warning #213
Labels
No labels
Alpha Release Requirement
Bugfix
Demo Target
Documentation
Major Feature
Minor Feature
priority:tier1-active
priority:tier2-foundation
priority:tier3-future
priority:tier4-deferred
Refactoring & Cleanup
system:animation
system:documentation
system:grid
system:input
system:performance
system:procgen
system:python-binding
system:rendering
system:ui-hierarchy
Tiny Feature
workflow:blocked
workflow:needs-benchmark
workflow:needs-documentation
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
john/McRogueFace#213
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
In
ParseColorArg(GridLayers.cpp:113-121), color component values are accepted as arbitrary integers and passed directly tosf::Color, which usessf::Uint8(unsigned 8-bit). Values outside the valid 0-255 range wrap silently due to integer overflow.Example
Impact
Proposed Solution
Add validation with either:
ValueErrorif any component is outside 0-255UserWarningand clamp values to valid rangeOption 1 is stricter but catches bugs. Option 2 is more forgiving for edge cases.
Affected Code
GridLayers.cpp:ParseColorArg()helper functionColorLayer.apply_threshold(),ColorLayer.apply_gradient(),ColorLayer.apply_ranges()ColorLayer.fill(),ColorLayer.set(),ColorLayer.fill_rect()(which have their own inline parsing)Related
Discovered during code review of #200 and #201 implementations.