From 6566a2ae7d6c931862294b482d96e157ba737908 Mon Sep 17 00:00:00 2001 From: Yamagi Date: Sat, 21 Jan 2023 16:43:27 +0100 Subject: [PATCH] Handle case that ResizeSTB() failed. This unlikely, however the compiler printed a warning that `image` may be used uninitialized. --- src/client/refresh/soft/sw_image.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/client/refresh/soft/sw_image.c b/src/client/refresh/soft/sw_image.c index ff08a039..2b7d9bad 100644 --- a/src/client/refresh/soft/sw_image.c +++ b/src/client/refresh/soft/sw_image.c @@ -376,8 +376,7 @@ R_LoadPic (char *name, byte *pic, int width, int realwidth, int height, int real // resize image pic32 = malloc(uploadwidth * uploadheight * 4); - if (ResizeSTB(pic, width, height, - pic32, uploadwidth, uploadheight)) + if (ResizeSTB(pic, width, height, pic32, uploadwidth, uploadheight)) { R_Convert32To8bit(pic32, pic8, uploadwidth * uploadheight, type != it_wall); image = R_LoadPic8(name, pic8, @@ -385,6 +384,14 @@ R_LoadPic (char *name, byte *pic, int width, int realwidth, int height, int real uploadheight, realheight, uploadwidth * uploadheight, type); } + else + { + R_Convert32To8bit(pic, pic8, data_size, type != it_wall); + image = R_LoadPic8 (name, pic8, + width, realwidth, + height, realheight, + data_size, type); + } free(pic32); } else