termptyesc: avoid issue with integer promotion

Found by UBSan:
sgr-truecolors.sh... ../src/bin/termptyesc.c:737:35: runtime error: left
shift of 244 by 24 places cannot be represented in type 'int'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior
../src/bin/termptyesc.c:737:35 in
This commit is contained in:
Boris Faure 2020-04-22 23:52:58 +02:00
parent f9b6f88be1
commit 00c427a20f
Signed by: borisfaure
GPG Key ID: 35C0410516166BE8
1 changed files with 4 additions and 1 deletions

View File

@ -734,7 +734,10 @@ _approximate_truecolor_rgb(Termpty *ty, int r0, int g0, int b0)
int c;
int distance_min = INT_MAX;
Evas_Object *textgrid;
const uint32_t color_msb = (r0 << 24) | (g0 << 16) | (b0 << 8);
const uint32_t color_msb = 0
| (((uint8_t)r0) << 24)
| (((uint8_t)g0) << 16)
| (((uint8_t)b0) << 8);
if (_tcc_find(color_msb, &chosen_color))
return chosen_color;