From be0c062c5be2da0152803259078e201bbe86a2a8 Mon Sep 17 00:00:00 2001
From: Alam Ed Arias <alam@srb2.org>
Date: Mon, 9 May 2016 20:10:14 -0400
Subject: [PATCH] Precache: fix off by one, making the precache code write into
 memory it should not be touching

---
 src/r_data.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/r_data.c b/src/r_data.c
index 3a7fb602ed..34141489f9 100644
--- a/src/r_data.c
+++ b/src/r_data.c
@@ -1604,7 +1604,7 @@ void R_PrecacheLevel(void)
 	//
 	// no need to precache all software textures in 3D mode
 	// (note they are still used with the reference software view)
-	texturepresent = calloc(numtextures, sizeof (*texturepresent));
+	texturepresent = calloc(numtextures+1, sizeof (*texturepresent));
 	if (texturepresent == NULL) I_Error("%s: Out of memory looking up textures", "R_PrecacheLevel");
 
 	for (j = 0; j < numsides; j++)
-- 
GitLab