mirror of
https://git.sr.ht/~leon_plickat/wayneko
synced 2025-09-19 16:03:22 +02:00
better check for bad colours
This commit is contained in:
parent
85e100a3a1
commit
a8e6c36941
1 changed files with 6 additions and 0 deletions
|
@ -911,6 +911,12 @@ static void timespec_diff (struct timespec *a, struct timespec *b, struct timesp
|
||||||
|
|
||||||
static bool colour_from_hex (pixman_color_t *colour, const char *hex)
|
static bool colour_from_hex (pixman_color_t *colour, const char *hex)
|
||||||
{
|
{
|
||||||
|
if ( strlen(hex) != strlen("0xRRGGBBAA") && strlen(hex) != strlen("0xRRGGBB") )
|
||||||
|
{
|
||||||
|
fprintf(stderr, "ERROR: Invalid colour: %s\n", hex);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
uint16_t r = 0, g = 0, b = 0, a = 255;
|
uint16_t r = 0, g = 0, b = 0, a = 255;
|
||||||
|
|
||||||
if ( 4 != sscanf(hex, "0x%02hx%02hx%02hx%02hx", &r, &g, &b, &a)
|
if ( 4 != sscanf(hex, "0x%02hx%02hx%02hx%02hx", &r, &g, &b, &a)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue