summaryrefslogtreecommitdiffstats
path: root/apps/plugins/mikmod/load_stx.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/mikmod/load_stx.c')
-rw-r--r--apps/plugins/mikmod/load_stx.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/apps/plugins/mikmod/load_stx.c b/apps/plugins/mikmod/load_stx.c
index ac6e51f4c7..db25813342 100644
--- a/apps/plugins/mikmod/load_stx.c
+++ b/apps/plugins/mikmod/load_stx.c
@@ -6,12 +6,12 @@
it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Library General Public License for more details.
-
+
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
@@ -20,7 +20,7 @@
/*==============================================================================
- $Id: load_stx.c,v 1.3 2005/04/07 19:57:38 realtech Exp $
+ $Id$
STMIK 0.2 (STX) module loader
@@ -114,13 +114,14 @@ static int STX_Test(void)
UBYTE id[8];
int t;
+ memset(id,0,8);
_mm_fseek(modreader,0x3C,SEEK_SET);
if(!_mm_read_UBYTES(id,4,modreader)) return 0;
if(memcmp(id,"SCRM",4)) return 0;
_mm_fseek(modreader,0x14,SEEK_SET);
if(!_mm_read_UBYTES(id,8,modreader)) return 0;
-
+
for(t=0;t<STM_NTRACKERS;t++)
if(!memcmp(id,STM_Signatures[t],8)) return 1;
@@ -143,6 +144,10 @@ static void STX_Cleanup(void)
MikMod_free(paraptr);
MikMod_free(poslookup);
MikMod_free(mh);
+ stxbuf=NULL;
+ paraptr=NULL;
+ poslookup=NULL;
+ mh=NULL;
}
static int STX_ReadPattern(void)
@@ -297,6 +302,11 @@ static int STX_Load(int curious)
_mm_errno = MMERR_LOADING_HEADER;
return 0;
}
+ if(mh->ordnum > 256 || !mh->insnum || mh->insnum > 256 ||
+ mh->patnum > 254 || !mh->patnum) {
+ _mm_errno = MMERR_NOT_A_MODULE;
+ return 0;
+ }
/* set module variables */
of.songname = DupStr(mh->songname,20,1);
@@ -323,10 +333,10 @@ static int STX_Load(int curious)
version=_mm_read_I_UWORD(modreader);
if(version==mh->patsize) {
version = 0x10;
- of.modtype = StrDup("STMIK 0.2 (STM2STX 1.0)");
+ of.modtype = MikMod_strdup("STMIK 0.2 (STM2STX 1.0)");
} else {
version = 0x11;
- of.modtype = StrDup("STMIK 0.2 (STM2STX 1.1)");
+ of.modtype = MikMod_strdup("STMIK 0.2 (STM2STX 1.1)");
}
/* read the order data */
@@ -343,7 +353,7 @@ static int STX_Load(int curious)
if(order==255) order=LAST_PATTERN;
of.positions[of.numpos]=order;
poslookup[t]=of.numpos; /* bug fix for freaky S3Ms */
- if(of.positions[t]<254) of.numpos++;
+ if(of.positions[t]<254) of.numpos++;
else
/* special end of song pattern */
if((order==LAST_PATTERN)&&(!curious)) break;
@@ -389,7 +399,7 @@ static int STX_Load(int curious)
q->loopstart = s.loopbeg;
q->loopend = s.loopend;
q->volume = s.volume;
- q->seekpos = (((long)s.memsegh)<<16|s.memsegl)<<4;
+ q->seekpos = (((ULONG)s.memsegh)<<16|s.memsegl)<<4;
q->flags |= SF_SIGNED;
if(s.flags&1) q->flags |= SF_LOOP;