diff --git a/src/modules/vmath.c b/src/modules/vmath.c index e1ec64a3..e55a1777 100644 --- a/src/modules/vmath.c +++ b/src/modules/vmath.c @@ -896,7 +896,7 @@ static bool color32_from_hex_STATIC(int argc, py_Ref argv) { c11_color32 color; int res; if(hex.size == 7) { - res = scanf(hex.data, "#%2hhx%2hhx%2hhx", &color.r, &color.g, &color.b); + res = sscanf(hex.data, "#%2hhx%2hhx%2hhx", &color.r, &color.g, &color.b); if(res != 3) return ValueError("invalid hex color format"); color.a = 255; } else { diff --git a/tests/80_color32.py b/tests/80_color32.py index 49be5231..8bd748a3 100644 --- a/tests/80_color32.py +++ b/tests/80_color32.py @@ -12,6 +12,7 @@ assert a.with_a(255).a == 255 and a.with_a(255).g == a.g assert a.to_hex() == '#64c8ff78' assert color32.from_hex('#64c8ff78') == a +assert color32.from_hex('#64c8ff') == a.with_a(255) assert rgb(100, 200, 255) != a assert rgba(100, 200, 255, 120 / 255) == a