foxygit / doom Log in
commit 181c56fc2e28ede64e03b47252aaaad72fd2d3af
Author:     Wells Lu <55797333+wellslutw@users.noreply.github.com>
AuthorDate: Thu Mar 12 19:49:26 2020 +0800
Commit:     GitHub <noreply@github.com>
CommitDate: Thu Mar 12 12:49:26 2020 +0100

    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>
---
 src/i_video.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/i_video.c b/src/i_video.c
index 2f342fb4..12673173 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -1149,7 +1149,7 @@ static void SetVideoMode(void)
     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 @@ static void SetVideoMode(void)

     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);
     }