---
 loaders/load_it.c |    4 ++++
 1 file changed, 4 insertions(+)

--- libmikmod-3.1.12.orig/loaders/load_it.c
+++ libmikmod-3.1.12/loaders/load_it.c
@@ -743,6 +743,8 @@ BOOL IT_Load(BOOL curious)
 #define IT_LoadEnvelope(name,type) 										\
				ih. name##flg   =_mm_read_UBYTE(modreader);				\
				ih. name##pts   =_mm_read_UBYTE(modreader);				\
+				if (ih. name##pts > ITENVCNT)							\
+					ih. name##pts = ITENVCNT;							\
				ih. name##beg   =_mm_read_UBYTE(modreader);				\
				ih. name##end   =_mm_read_UBYTE(modreader);				\
				ih. name##susbeg=_mm_read_UBYTE(modreader);				\
@@ -756,6 +758,8 @@ BOOL IT_Load(BOOL curious)
 #define IT_LoadEnvelope(name,type) 										\
				ih. name/**/flg   =_mm_read_UBYTE(modreader);			\
				ih. name/**/pts   =_mm_read_UBYTE(modreader);			\
+				if (ih. name/**/pts > ITENVCNT)							\
+					ih. name/**/pts = ITENVCNT;							\
				ih. name/**/beg   =_mm_read_UBYTE(modreader);			\
				ih. name/**/end   =_mm_read_UBYTE(modreader);			\
				ih. name/**/susbeg=_mm_read_UBYTE(modreader);			\
