Skip to content

Commit

Permalink
fixed tokenizing of the Brightness token
Browse files Browse the repository at this point in the history
If the Brightness change was negative, the controller would crash
almost instantly, because the last check (*s == '-') would always be
true and the previous 2 checks would eventually access memory outside
of the RAM region which causes a HARDFAULT
  • Loading branch information
peterzuger committed Nov 5, 2019
1 parent d6df55d commit 8654ede
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tlc5947/tlc5947.c
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,9 @@ static void tokenize_pattern_str(const char* s, token_t* pat, size_t len){
dprintf("BRIGHTNESS\n\r");
pat[i].type = pBRIGHTNESS;
int len = 0;
while(isdigit(s[len]) || (s[len] == '.') || (*s == '-'))
if(*s == '-')
len++;
while(isdigit(s[len]) || (s[len] == '.'))
len++;
pat[i].brighness.brightness = atof(s);
s += len;
Expand Down

0 comments on commit 8654ede

Please sign in to comment.