You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(channels): guard Channel::applyAddressing against zero-width XYMap and OOM - #5496
Return early in ReorderingPixelIteratorAny::applyAddressing() if width == 0, height == 0, or numLeds == 0, preventing divide-by-zero in physicalIdx % width / physicalIdx / width.
Compute expectedLeds in u32 to avoid u16 multiplication overflow.
Check buffer.size() == numLeds after buffer.resize(numLeds) so an allocation failure logs an error and falls back to the un-reordered pixels instead of writing out of bounds.
CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.
Parsing warnings: 1
Validation error: Unrecognized key: "enabled" at "reviews.pre_merge_checks"
If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Walkthrough
applyAddressing now bypasses XYMap reordering for zero dimensions or a zero LED count. It calculates the expected map size with 32-bit multiplication and checks the resized buffer size. A unit test verifies that a zero-width map preserves both input pixels.
Changes: XYMap Reordering
Layer / File(s)
Summary
Reordering guards and regression test src/fl/channels/channel.cpp.hpp, tests/unit/fl/channels/channel.cpp
applyAddressing returns the original pixels when map dimensions or LED count are zero, or when the resized reorder buffer does not match the LED count. The expected map size uses 32-bit multiplication. A unit test checks that showing a channel with a zero-width map preserves both input pixels.
This change prevents a divide-by-zero and an overflow-related allocation problem when a channel is given an invalid zero-sized map. The affected path now falls back to the original pixels. Tests cover the zero-width case, and no merge-blocking risk remains.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the main change: guarding Channel::applyAddressing against a zero-width XYMap and against out-of-memory conditions. The raw summary describes exactly this: an early return for zero map…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title names the main change: guarding Channel::applyAddressing against a zero-width XYMap and against out-of-memory conditions. The raw summary describes exactly this: an early return for zero map dimensions or LED count, a 32-bit expected-LED calculation to avoid overflow, and an error-logging fallback when the resized buffer has the wrong size. The added regression test for a zero-width XYMap also matches the title. The title is specific and follows the conventional-commit style, so it passes.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Reviewing files that changed from the base of the PR and between a1789a4 and 0113b17.
Files selected for processing: 2
src/fl/channels/channel.cpp.hpp
tests/unit/fl/channels/channel.cpp
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 1 remain after this review.
Change in examples/Blink per target. The left number is this PR's image flash / attributed RAM in bytes; the colored delta is the change from the merge base (red ↑ is larger, green ↓ is smaller, Same is unchanged).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements #5492 item #13.
ReorderingPixelIteratorAny::applyAddressing()ifwidth == 0,height == 0, ornumLeds == 0, preventing divide-by-zero inphysicalIdx % width/physicalIdx / width.expectedLedsinu32to avoidu16multiplication overflow.buffer.size() == numLedsafterbuffer.resize(numLeds)so an allocation failure logs an error and falls back to the un-reordered pixels instead of writing out of bounds.Verification
bash lint src/fl/channels/channel.cpp.hpp tests/unit/fl/channels/channel.cpp— passedbash test channel --debug(ASAN/LSAN/UBSAN) — passed (including new zero-width XYMap regression test)Summary by CodeRabbit