From 16d7a78efe14d345a6c5b241f88422ad0ee483ea Mon Sep 17 00:00:00 2001
From: Konstanty Bialkowski <metaplasma@users.sourceforge.net>
Date: Mon, 25 Jul 2011 08:22:36 +1000
Subject: [PATCH] AMSv2 off by one problem (related to SA45131/C)

---
 libmodplug/src/load_ams.cpp |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/libmodplug/src/load_ams.cpp b/libmodplug/src/load_ams.cpp
index 4a29087..b05e5ab 100644
--- a/libmodplug/src/load_ams.cpp
+++ b/libmodplug/src/load_ams.cpp
@@ -321,7 +321,7 @@ BOOL CSoundFile::ReadAMS2(LPCBYTE lpStream, DWORD dwMemLength)
 	dwMemPos = pfh->titlelen + 8;
 	psh = (AMS2SONGHEADER *)(lpStream + dwMemPos);
 	if (((psh->version & 0xFF00) != 0x0200) || (!psh->instruments)
-	 || (psh->instruments > MAX_INSTRUMENTS) || (!psh->patterns) || (!psh->orders)) return FALSE;
+	 || (psh->instruments >= MAX_INSTRUMENTS) || (!psh->patterns) || (!psh->orders)) return FALSE;
 	dwMemPos += sizeof(AMS2SONGHEADER);
 	if (pfh->titlelen)
 	{
-- 
1.7.0.1

