From 6ea69d6d86e01cc377e91f81e3334075a916530c Mon Sep 17 00:00:00 2001
From: deuce <>
Date: Fri, 3 Jan 2014 00:39:46 +0000
Subject: [PATCH] Fix crash when decompressing on FreeBSD. This does not fix
 the underlying problem, just prevents twiddling outside of the array bounds.

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

diff --git a/src/encode/lzh.c b/src/encode/lzh.c
index bb364e2f56..f28251fc58 100644
--- a/src/encode/lzh.c
+++ b/src/encode/lzh.c
@@ -468,7 +468,7 @@ static void lzh_update(lzh_t* lzh, short int c)
 
 			c = l;
 		}
-	} while ((c = lzh->prnt[c]) != 0);	/* do it until reaching the root */
+	} while (((c = lzh->prnt[c]) != 0) && c < (sizeof(lzh->son)/sizeof(lzh->son[0])));	/* do it until reaching the root */
 }
 
 static void lzh_encode_char(lzh_t* lzh, unsigned short c, uint8_t *outbuf, int32_t *outlen)
-- 
GitLab