diff options
Diffstat (limited to 'apps/plugins/mikmod/load_stx.c')
-rw-r--r-- | apps/plugins/mikmod/load_stx.c | 26 |
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 @@ | |||
6 | it under the terms of the GNU Library General Public License as | 6 | it under the terms of the GNU Library General Public License as |
7 | published by the Free Software Foundation; either version 2 of | 7 | published by the Free Software Foundation; either version 2 of |
8 | the License, or (at your option) any later version. | 8 | the License, or (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU Library General Public License for more details. | 13 | GNU Library General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Library General Public | 15 | You should have received a copy of the GNU Library General Public |
16 | License along with this library; if not, write to the Free Software | 16 | License along with this library; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
@@ -20,7 +20,7 @@ | |||
20 | 20 | ||
21 | /*============================================================================== | 21 | /*============================================================================== |
22 | 22 | ||
23 | $Id: load_stx.c,v 1.3 2005/04/07 19:57:38 realtech Exp $ | 23 | $Id$ |
24 | 24 | ||
25 | STMIK 0.2 (STX) module loader | 25 | STMIK 0.2 (STX) module loader |
26 | 26 | ||
@@ -114,13 +114,14 @@ static int STX_Test(void) | |||
114 | UBYTE id[8]; | 114 | UBYTE id[8]; |
115 | int t; | 115 | int t; |
116 | 116 | ||
117 | memset(id,0,8); | ||
117 | _mm_fseek(modreader,0x3C,SEEK_SET); | 118 | _mm_fseek(modreader,0x3C,SEEK_SET); |
118 | if(!_mm_read_UBYTES(id,4,modreader)) return 0; | 119 | if(!_mm_read_UBYTES(id,4,modreader)) return 0; |
119 | if(memcmp(id,"SCRM",4)) return 0; | 120 | if(memcmp(id,"SCRM",4)) return 0; |
120 | 121 | ||
121 | _mm_fseek(modreader,0x14,SEEK_SET); | 122 | _mm_fseek(modreader,0x14,SEEK_SET); |
122 | if(!_mm_read_UBYTES(id,8,modreader)) return 0; | 123 | if(!_mm_read_UBYTES(id,8,modreader)) return 0; |
123 | 124 | ||
124 | for(t=0;t<STM_NTRACKERS;t++) | 125 | for(t=0;t<STM_NTRACKERS;t++) |
125 | if(!memcmp(id,STM_Signatures[t],8)) return 1; | 126 | if(!memcmp(id,STM_Signatures[t],8)) return 1; |
126 | 127 | ||
@@ -143,6 +144,10 @@ static void STX_Cleanup(void) | |||
143 | MikMod_free(paraptr); | 144 | MikMod_free(paraptr); |
144 | MikMod_free(poslookup); | 145 | MikMod_free(poslookup); |
145 | MikMod_free(mh); | 146 | MikMod_free(mh); |
147 | stxbuf=NULL; | ||
148 | paraptr=NULL; | ||
149 | poslookup=NULL; | ||
150 | mh=NULL; | ||
146 | } | 151 | } |
147 | 152 | ||
148 | static int STX_ReadPattern(void) | 153 | static int STX_ReadPattern(void) |
@@ -297,6 +302,11 @@ static int STX_Load(int curious) | |||
297 | _mm_errno = MMERR_LOADING_HEADER; | 302 | _mm_errno = MMERR_LOADING_HEADER; |
298 | return 0; | 303 | return 0; |
299 | } | 304 | } |
305 | if(mh->ordnum > 256 || !mh->insnum || mh->insnum > 256 || | ||
306 | mh->patnum > 254 || !mh->patnum) { | ||
307 | _mm_errno = MMERR_NOT_A_MODULE; | ||
308 | return 0; | ||
309 | } | ||
300 | 310 | ||
301 | /* set module variables */ | 311 | /* set module variables */ |
302 | of.songname = DupStr(mh->songname,20,1); | 312 | of.songname = DupStr(mh->songname,20,1); |
@@ -323,10 +333,10 @@ static int STX_Load(int curious) | |||
323 | version=_mm_read_I_UWORD(modreader); | 333 | version=_mm_read_I_UWORD(modreader); |
324 | if(version==mh->patsize) { | 334 | if(version==mh->patsize) { |
325 | version = 0x10; | 335 | version = 0x10; |
326 | of.modtype = StrDup("STMIK 0.2 (STM2STX 1.0)"); | 336 | of.modtype = MikMod_strdup("STMIK 0.2 (STM2STX 1.0)"); |
327 | } else { | 337 | } else { |
328 | version = 0x11; | 338 | version = 0x11; |
329 | of.modtype = StrDup("STMIK 0.2 (STM2STX 1.1)"); | 339 | of.modtype = MikMod_strdup("STMIK 0.2 (STM2STX 1.1)"); |
330 | } | 340 | } |
331 | 341 | ||
332 | /* read the order data */ | 342 | /* read the order data */ |
@@ -343,7 +353,7 @@ static int STX_Load(int curious) | |||
343 | if(order==255) order=LAST_PATTERN; | 353 | if(order==255) order=LAST_PATTERN; |
344 | of.positions[of.numpos]=order; | 354 | of.positions[of.numpos]=order; |
345 | poslookup[t]=of.numpos; /* bug fix for freaky S3Ms */ | 355 | poslookup[t]=of.numpos; /* bug fix for freaky S3Ms */ |
346 | if(of.positions[t]<254) of.numpos++; | 356 | if(of.positions[t]<254) of.numpos++; |
347 | else | 357 | else |
348 | /* special end of song pattern */ | 358 | /* special end of song pattern */ |
349 | if((order==LAST_PATTERN)&&(!curious)) break; | 359 | if((order==LAST_PATTERN)&&(!curious)) break; |
@@ -389,7 +399,7 @@ static int STX_Load(int curious) | |||
389 | q->loopstart = s.loopbeg; | 399 | q->loopstart = s.loopbeg; |
390 | q->loopend = s.loopend; | 400 | q->loopend = s.loopend; |
391 | q->volume = s.volume; | 401 | q->volume = s.volume; |
392 | q->seekpos = (((long)s.memsegh)<<16|s.memsegl)<<4; | 402 | q->seekpos = (((ULONG)s.memsegh)<<16|s.memsegl)<<4; |
393 | q->flags |= SF_SIGNED; | 403 | q->flags |= SF_SIGNED; |
394 | 404 | ||
395 | if(s.flags&1) q->flags |= SF_LOOP; | 405 | if(s.flags&1) q->flags |= SF_LOOP; |