Fix crash in SSWCP color_to_int for RGBA color strings#201
Open
appositeit wants to merge 1 commit intoSnapmaker:2.2.4-devfrom
Open
Fix crash in SSWCP color_to_int for RGBA color strings#201appositeit wants to merge 1 commit intoSnapmaker:2.2.4-devfrom
appositeit wants to merge 1 commit intoSnapmaker:2.2.4-devfrom
Conversation
The color_to_int lambda in sw_GetFileFilamentMapping crashes when parsing 9-character RGBA color strings like "#FFFFFFFF". The 8-digit branch uses oriclr[7-i] which evaluates to oriclr[-1] when i=8, causing an out-of-bounds access and SIGABRT. Fix by using oriclr[9-i] for the RGBA branch, matching the string length of 9 (index 8 down to 1, skipping the '#' at index 0). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
color_to_intlambda inSSWCP.cppthat crashes when parsing 9-character RGBA color strings (e.g."#FFFFFFFF")oriclr[7 - i]which evaluates tooriclr[-1]wheni=8, wrapping tostd::string::nposand causing SIGABRToriclr[9 - i]for the RGBA branch to correctly index from the end of the 9-character stringRoot Cause
The
color_to_intlambda validates thatoriclris either 7 or 9 characters starting with#. For the 7-character case (#RRGGBB), the looporiclr[7 - i]foriin[1, 6]correctly accesses indices 6 down to 1. However, for the 9-character case (#RRGGBBAA), the sameoriclr[7 - i]formula is used withiin[1, 8], which accesses index -1 wheni=8.Reproduction
sw_GetFileFilamentMappingcommand triggerscolor_to_intwith an RGBA color stringGDB Backtrace
Test plan
-fsanitize=address -O2) and successfully sending print jobs without crash🤖 Generated with Claude Code