if the colour value is unusable do not assign garbage to teh option

This commit is contained in:
Vincent Sanders 2013-05-28 20:14:49 +01:00
parent 2dec72b4d5
commit 06d87fec2b
1 changed files with 5 additions and 4 deletions

View File

@ -103,10 +103,11 @@ strtooption(const char *value, struct nsoption_s *option)
break;
case OPTION_COLOUR:
sscanf(value, "%x", &rgbcolour);
option->value.c = (((0x000000FF & rgbcolour) << 16) |
((0x0000FF00 & rgbcolour) << 0) |
((0x00FF0000 & rgbcolour) >> 16));
if (sscanf(value, "%x", &rgbcolour) == 1) {
option->value.c = (((0x000000FF & rgbcolour) << 16) |
((0x0000FF00 & rgbcolour) << 0) |
((0x00FF0000 & rgbcolour) >> 16));
}
break;
case OPTION_STRING: