ref: 181c56fc2e28ede64e03b47252aaaad72fd2d3af
parent: f1fa7faf566e3e325c1b1fbf8ace8d5ac2db2b1e
author: Wells Lu <55797333+wellslutw@users.noreply.github.com>
date: Thu Mar 12 15:49:26 EDT 2020
Fix segmentation fault when running on rgb565 screen (#1255) Pixel depth of rgb565 format is 16, instead of 32. Using fixed value of 32 causes Segmentation fault when run the statement: SDL_LowerBlit(screenbuffer, &blit_rect, rgbabuffer, &blit_rect) Co-authored-by: wells <wells.lu@sunext.com>
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -1149,7 +1149,7 @@
int w, h;
int x, y;
unsigned int rmask, gmask, bmask, amask;
- int unused_bpp;
+ int bpp;
int window_flags = 0, renderer_flags = 0;
SDL_DisplayMode mode;
@@ -1321,10 +1321,10 @@
if (argbbuffer == NULL)
{
- SDL_PixelFormatEnumToMasks(pixel_format, &unused_bpp,
+ SDL_PixelFormatEnumToMasks(pixel_format, &bpp,
&rmask, &gmask, &bmask, &amask);
argbbuffer = SDL_CreateRGBSurface(0,
- SCREENWIDTH, SCREENHEIGHT, 32,
+ SCREENWIDTH, SCREENHEIGHT, bpp,
rmask, gmask, bmask, amask);
SDL_FillRect(argbbuffer, NULL, 0);
}