# SDL: More "Integer overflow generates Illegal instruction under sanitizers" (see bug #4995)

**URL:** <https://discourse.libsdl.org/t/sdl-more-integer-overflow-generates-illegal-instruction-under-sanitizers-see-bug-4995/33650>\
**Category:** SDL Commits\
**Created:** [November 23, 2021, 8:42am UTC](https://discourse.libsdl.org/t/sdl-more-integer-overflow-generates-illegal-instruction-under-sanitizers-see-bug-4995/33650 "2021-11-23T08:42:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SDLPushPostBot](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/sdlpushpostbot/32/4370_2.png) [@SDLPushPostBot](https://discourse.libsdl.org/u/SDLPushPostBot)\
**Post date:** [November 23, 2021, 8:42am UTC](https://discourse.libsdl.org/t/sdl-more-integer-overflow-generates-illegal-instruction-under-sanitizers-see-bug-4995/33650/1 "2021-11-23T08:42:01Z")

</div>

> <https://github.com/libsdl-org/SDL/commit/9c72adc86c316d8f1f72a171a977b86b5f90f4f7>

```diff
From 9c72adc86c316d8f1f72a171a977b86b5f90f4f7 Mon Sep 17 00:00:00 2001
From: Sylvain <[EMAIL REDACTED]>
Date: Tue, 23 Nov 2021 09:41:01 +0100
Subject: [PATCH] More "Integer overflow generates Illegal instruction under
 sanitizers" (see bug #4995)

---
 src/video/SDL_pixels.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/video/SDL_pixels.c b/src/video/SDL_pixels.c
index eff0c94085c..ac04533c5d5 100644
--- a/src/video/SDL_pixels.c
+++ b/src/video/SDL_pixels.c
@@ -871,7 +871,7 @@ SDL_MapRGBA(const SDL_PixelFormat * format, Uint8 r, Uint8 g, Uint8 b,
         return (r >> format->Rloss) << format->Rshift
             | (g >> format->Gloss) << format->Gshift
             | (b >> format->Bloss) << format->Bshift
- | ((a >> format->Aloss) << format->Ashift & format->Amask);
+ | ((Uint32)(a >> format->Aloss) << format->Ashift & format->Amask);
     } else {
         return SDL_FindColor(format->palette, r, g, b, a);
     }
@@ -983,7 +983,7 @@ Map1toN(SDL_PixelFormat * src, Uint8 Rmod, Uint8 Gmod, Uint8 Bmod, Uint8 Amod,
         Uint8 G = (Uint8) ((pal->colors[i].g * Gmod) / 255);
         Uint8 B = (Uint8) ((pal->colors[i].b * Bmod) / 255);
         Uint8 A = (Uint8) ((pal->colors[i].a * Amod) / 255);
- ASSEMBLE_RGBA(&map[i * bpp], dst->BytesPerPixel, dst, R, G, B, A);
+ ASSEMBLE_RGBA(&map[i * bpp], dst->BytesPerPixel, dst, (Uint32)R, (Uint32)G, (Uint32)B, (Uint32)A);
     }
     return (map);
 }

```
