From 45922f80d1e35aadc9da6e20fa32fa78c1044dfd Mon Sep 17 00:00:00 2001
From: Sryder <sryder13@gmail.com>
Date: Sun, 23 Jun 2019 12:26:52 +0100
Subject: [PATCH] Don't read from a per-map COLORMAP if it is too big. Could
 this be changed to only read the first so many bytes?

---
 src/r_data.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/r_data.c b/src/r_data.c
index a21ba49ae9..bf570e3ab2 100644
--- a/src/r_data.c
+++ b/src/r_data.c
@@ -1073,6 +1073,15 @@ void R_ReInitColormaps(UINT16 num)
 	lump = W_GetNumForName(colormap);
 	if (lump == LUMPERROR)
 		lump = W_GetNumForName("COLORMAP");
+	else
+	{
+		if (W_LumpLength(lump) > W_LumpLength(W_GetNumForName("COLORMAP")))
+		{
+			CONS_Alert(CONS_WARNING, "%s lump size is too big, using COLORMAP.\n", colormap);
+			lump = W_GetNumForName("COLORMAP");
+		}
+	}
+
 	W_ReadLump(lump, colormaps);
 
 	// Init Boom colormaps.
-- 
GitLab