Skip to content

Commit 2926cc2

Browse files
1bsylslouken
authored andcommitted
Fix ASAN reports: runtime error: left shift of XXX by 24 places cannot be represented in type 'int'
(cherry picked from commit ba51905)
1 parent f75fb29 commit 2926cc2

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

SDL_ttf.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ static SDL_INLINE void BG_Blended_Opaque_SDF(const TTF_Image *image, Uint32 *des
510510
/* *INDENT-OFF* */
511511
DUFFS_LOOP4(
512512
d = *dst;
513-
s = *src++ << 24;
513+
s = ((Uint32)*src++) << 24;
514514
if (s > d) {
515515
*dst = s;
516516
}
@@ -564,7 +564,7 @@ static SDL_INLINE void BG_Blended_Opaque(const TTF_Image *image, Uint32 *destina
564564
while (height--) {
565565
/* *INDENT-OFF* */
566566
DUFFS_LOOP4(
567-
*dst++ |= *src++ << 24;
567+
*dst++ |= ((Uint32)*src++) << 24;
568568
, width);
569569
/* *INDENT-ON* */
570570
src += srcskip;
@@ -605,10 +605,10 @@ static SDL_INLINE void BG_Blended_Opaque_32(const TTF_Image *image, Uint32 *dest
605605
while (height--) {
606606
/* *INDENT-OFF* */
607607
DUFFS_LOOP4(
608-
*dst++ |= *src++ << 24;
609-
*dst++ |= *src++ << 24;
610-
*dst++ |= *src++ << 24;
611-
*dst++ |= *src++ << 24;
608+
*dst++ |= ((Uint32)*src++) << 24;
609+
*dst++ |= ((Uint32)*src++) << 24;
610+
*dst++ |= ((Uint32)*src++) << 24;
611+
*dst++ |= ((Uint32)*src++) << 24;
612612
, width);
613613
/* *INDENT-ON* */
614614
src += srcskip;
@@ -1574,7 +1574,7 @@ static SDL_Surface *Create_Surface_Blended(int width, int height, SDL_Color fg,
15741574
bgcolor = (fg.r << 16) | (fg.g << 8) | fg.b;
15751575

15761576
/* Underline/Strikethrough color style */
1577-
*color = bgcolor | (fg.a << 24);
1577+
*color = bgcolor | ((Uint32)fg.a << 24);
15781578

15791579
/* Create the target surface if required */
15801580
if (width != 0) {
@@ -1598,10 +1598,10 @@ static SDL_Surface* Create_Surface_LCD(int width, int height, SDL_Color fg, SDL_
15981598
Uint32 bgcolor;
15991599

16001600
/* Background color */
1601-
bgcolor = (bg.a << 24) | (bg.r << 16) | (bg.g << 8) | bg.b;
1601+
bgcolor = (((Uint32)bg.a) << 24) | (bg.r << 16) | (bg.g << 8) | bg.b;
16021602

16031603
/* Underline/Strikethrough color style */
1604-
*color = (bg.a << 24) | (fg.r << 16) | (fg.g << 8) | fg.b;
1604+
*color = (((Uint32)bg.a) << 24) | (fg.r << 16) | (fg.g << 8) | fg.b;
16051605

16061606
/* Create the target surface if required */
16071607
if (width != 0) {

0 commit comments

Comments
 (0)