From 8202ea86b764f1f6be5a15393a7e68cdc29804b4 Mon Sep 17 00:00:00 2001
From: Jaime Passos <lazymyuutsu@gmail.com>
Date: Tue, 7 Jan 2020 19:22:47 -0300
Subject: [PATCH] Fix Picture_GetPatchPixel

---
 src/r_picformats.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/r_picformats.c b/src/r_picformats.c
index 27d4c010f8..cb235590a4 100644
--- a/src/r_picformats.c
+++ b/src/r_picformats.c
@@ -532,14 +532,20 @@ void *Picture_GetPatchPixel(
 				if ((topdelta + ofs) == y)
 				{
 					if (informat == PICFMT_PATCH32)
-						return (s32 + ofs);
+						return &s32[ofs];
 					else if (informat == PICFMT_PATCH16)
-						return (s16 + ofs);
+						return &s16[ofs];
 					else // PICFMT_PATCH
-						return (s8 + ofs);
+						return &s8[ofs];
 				}
 			}
-			column = (column_t *)((UINT8 *)column + column->length + 4);
+			if (informat == PICFMT_PATCH32)
+				column = (column_t *)((UINT32 *)column + column->length);
+			else if (informat == PICFMT_PATCH16)
+				column = (column_t *)((UINT16 *)column + column->length);
+			else
+				column = (column_t *)((UINT8 *)column + column->length);
+			column = (column_t *)((UINT8 *)column + 4);
 		}
 	}
 
-- 
GitLab