Ryujinx-SDL/src/video
Sam Lantinga 1da252c2d8 Fixed crash in bug 3367 - RGBA_FROM_PIXEL macro can't handle SDL_PIXELFORMAT_ARGB2101010
Simon Hug

The RGBA_FROM_PIXEL macro in src/video/blit.h [1] is not designed to work with more than 8 bits per channel and the ARGB2101010 format makes it read outside of the array bounds causing access violations. This can happen during blitting with the BlitNtoNPixelAlpha and SDL_Blit_Slow functions.

When SDL_InitFormat tries to calculate the loss of the channels [2], the Uint8 will wrap around and it will end up at 254 for the 10-bit channels. Clearly way over the 9 entries of the SDL_expand_byte array. (Not that a signed integer would help.) Then the macro tries to access the lookup table with the channel value which could be up to 1023. If the previous indirection didn't cause an access violation this one will.

I guess it's not worth modifying this macro for a format that only a few will use. It will only make the other blitters slower. I don't have good ideas to solve this issue.

Attached is a test case that does three blits. A copy one that work and the two that use the functions mentioned above.

[1] https://hg.libsdl.org/SDL/file/cd1994d4f3c6/src/video/SDL_blit.h#l303
[2] https://hg.libsdl.org/SDL/file/cd1994d4f3c6/src/video/SDL_pixels.c#l540
2017-08-11 18:56:41 -07:00
..
android Fixed bug 3690 - SDL2 KMS/DRM render context support 2017-08-02 10:22:48 -07:00
cocoa Fixed bug 3697 - Main thread gets stuck on left mouse down 2017-08-01 20:16:10 -07:00
directfb directfb: Fixed quitting keyboard twice. 2017-06-16 23:30:30 +02:00
dummy Updated copyright for 2017 2017-01-01 18:33:28 -08:00
emscripten emscripten: Fixed compiling without OpenGL support. 2017-08-05 22:10:48 +02:00
haiku haiku: Fixed compiler warning. 2017-08-09 18:30:48 -04:00
kmsdrm Fixed bug 3723 - Possible double free in kmsdrm init code on certain errors 2017-08-11 10:05:45 -07:00
mir mir: Removed unnecessary function declaration. 2017-08-05 22:10:15 +02:00
nacl nacl: Fixed freeing static memory on video quit. 2017-08-05 22:10:25 +02:00
pandora pandora: Fixed compile error. 2017-06-16 23:30:38 +02:00
psp Fixed SDL_GetWindowWMInfo() returning success on three unsupported platforms. 2017-06-15 23:30:29 +02:00
qnx Fixed compiler warnings on QNX. 2017-07-23 19:25:16 -04:00
raspberry Fixed bug 3690 - SDL2 KMS/DRM render context support 2017-08-02 10:22:48 -07:00
uikit iOS: Use modern replacements for deprecated functions, when available. 2017-07-15 17:41:58 -03:00
vivante Fixed bug 3690 - SDL2 KMS/DRM render context support 2017-08-02 10:22:48 -07:00
wayland Fixed bug 3690 - SDL2 KMS/DRM render context support 2017-08-02 10:22:48 -07:00
windows Fixed bug 3702 - Clear error messages of SDL_LoadObject for optional libraries 2017-08-11 10:21:19 -07:00
winrt Fixed bug 3690 - SDL2 KMS/DRM render context support 2017-08-02 10:22:48 -07:00
x11 Fixed bug 3722 - Fall back to xinerama/xvidmode if xrandr modes initialization fails 2017-08-02 10:28:13 -07:00
SDL_blit_0.c Updated copyright for 2017 2017-01-01 18:33:28 -08:00
SDL_blit_1.c Updated copyright for 2017 2017-01-01 18:33:28 -08:00
SDL_blit_A.c Fix some more compiler warnings on armcc. 2017-03-03 16:38:17 -05:00
SDL_blit_auto.c Updated copyright for 2017 2017-01-01 18:33:28 -08:00
SDL_blit_auto.h Updated copyright for 2017 2017-01-01 18:33:28 -08:00
SDL_blit_copy.c Updated copyright for 2017 2017-01-01 18:33:28 -08:00
SDL_blit_copy.h Updated copyright for 2017 2017-01-01 18:33:28 -08:00
SDL_blit_N.c Fixed comment style. 2017-02-26 21:20:39 +01:00
SDL_blit_slow.c Updated copyright for 2017 2017-01-01 18:33:28 -08:00
SDL_blit_slow.h Updated copyright for 2017 2017-01-01 18:33:28 -08:00
SDL_blit.c Fixed crash in bug 3367 - RGBA_FROM_PIXEL macro can't handle SDL_PIXELFORMAT_ARGB2101010 2017-08-11 18:56:41 -07:00
SDL_blit.h Really fixed blit issue for capehill 2017-01-07 16:51:48 -08:00
SDL_bmp.c Fix some more compiler warnings on armcc. 2017-03-03 16:38:17 -05:00
SDL_clipboard.c Updated copyright for 2017 2017-01-01 18:33:28 -08:00
SDL_egl_c.h Fixed bug 3690 - SDL2 KMS/DRM render context support 2017-08-02 10:22:48 -07:00
SDL_egl.c Fixed bug 3702 - Clear error messages of SDL_LoadObject for optional libraries 2017-08-11 10:21:19 -07:00
SDL_fillrect.c Updated copyright for 2017 2017-01-01 18:33:28 -08:00
SDL_pixels_c.h Updated copyright for 2017 2017-01-01 18:33:28 -08:00
SDL_pixels.c Updated copyright for 2017 2017-01-01 18:33:28 -08:00
SDL_rect_c.h Updated copyright for 2017 2017-01-01 18:33:28 -08:00
SDL_rect.c Updated copyright for 2017 2017-01-01 18:33:28 -08:00
SDL_RLEaccel_c.h Updated copyright for 2017 2017-01-01 18:33:28 -08:00
SDL_RLEaccel.c Updated copyright for 2017 2017-01-01 18:33:28 -08:00
SDL_shape_internals.h Updated copyright for 2017 2017-01-01 18:33:28 -08:00
SDL_shape.c Fixed bug 3699 - Shaped windows are distorted unless width is divisible by 8 2017-07-11 08:16:00 -07:00
SDL_stretch.c Removed newlines from error messages. 2017-03-26 21:00:19 +02:00
SDL_surface.c Updated copyright for 2017 2017-01-01 18:33:28 -08:00
SDL_sysvideo.h Fixed bug 3690 - SDL2 KMS/DRM render context support 2017-08-02 10:22:48 -07:00
SDL_video.c Temporary hack to fix bug 3725 - Call made to glGetString before context creation 2017-08-04 13:06:56 -07:00
sdlgenblit.pl Updated copyright for 2017 2017-01-01 18:33:28 -08:00