diff options
Diffstat (limited to 'apps/plugins/mikmod/load_far.c')
-rw-r--r-- | apps/plugins/mikmod/load_far.c | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/apps/plugins/mikmod/load_far.c b/apps/plugins/mikmod/load_far.c index 2a1a44eda9..643cf15d49 100644 --- a/apps/plugins/mikmod/load_far.c +++ b/apps/plugins/mikmod/load_far.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_far.c,v 1.3 2005/04/07 19:57:38 realtech Exp $ + $Id$ Farandole (FAR) module loader @@ -92,7 +92,7 @@ static FARHEADER1 *mh1 = NULL; static FARHEADER2 *mh2 = NULL; static FARNOTE *pat = NULL; -static unsigned char FARSIG[4+3]={'F','A','R',0xfe,13,10,26}; +static const unsigned char FARSIG[4+3]={'F','A','R',0xfe,13,10,26}; /*========== Loader code */ @@ -119,6 +119,9 @@ static void FAR_Cleanup(void) MikMod_free(mh1); MikMod_free(mh2); MikMod_free(pat); + mh1 = NULL; + mh2 = NULL; + pat = NULL; } static UBYTE *FAR_ConvertTrack(FARNOTE* n,int rows) @@ -180,7 +183,7 @@ static int FAR_Load(int curious) FARSAMPLE s; FARNOTE *crow; UBYTE smap[8]; - (void)curious; + (void)curious; /* try to read module header (first part) */ _mm_read_UBYTES(mh1->id,4,modreader); @@ -196,7 +199,7 @@ static int FAR_Load(int curious) mh1->stlen = _mm_read_I_UWORD (modreader); /* init modfile data */ - of.modtype = StrDup(FAR_Version); + of.modtype = MikMod_strdup(FAR_Version); of.songname = DupStr(mh1->songname,40,1); of.numchn = 16; of.initspeed = mh1->speed; @@ -207,7 +210,12 @@ static int FAR_Load(int curious) /* read songtext into comment field */ if(mh1->stlen) - if (!ReadLinedComment(mh1->stlen, 66)) return 0; + if (!ReadLinedComment(mh1->stlen, 132)) return 0; + + if(_mm_eof(modreader)) { + _mm_errno = MMERR_LOADING_HEADER; + return 0; + } /* try to read module header (second part) */ _mm_read_UBYTES(mh2->orders,256,modreader); @@ -238,12 +246,14 @@ static int FAR_Load(int curious) if(!AllocPatterns()) return 0; for(t=0;t<of.numpat;t++) { - UBYTE rows=0/* ,tempo */; + UBYTE rows=0; + UBYTE tempo; memset(pat,0,256*16*4*sizeof(FARNOTE)); if(mh2->patsiz[t]) { rows = _mm_read_UBYTE(modreader); - /* tempo = */ (void)_mm_read_UBYTE(modreader); + tempo = _mm_read_UBYTE(modreader); + (void)tempo; /* unused */ crow = pat; /* file often allocates 64 rows even if there are less in pattern */ @@ -284,7 +294,7 @@ static int FAR_Load(int curious) of.numins = 0; for(t=0;t<64;t++) if(smap[t>>3]&(1<<(t&7))) of.numins=t+1; - of.numsmp = of.numins; + of.numsmp = of.numins; /* alloc sample structs */ if(!AllocSamples()) return 0; @@ -314,8 +324,8 @@ static int FAR_Load(int curious) q->seekpos = _mm_ftell(modreader); _mm_fseek(modreader,q->length,SEEK_CUR); - } else - q->samplename = DupStr(NULL,0,0); + } else + q->samplename = MikMod_strdup(""); q++; } return 1; @@ -327,8 +337,8 @@ static CHAR *FAR_LoadTitle(void) _mm_fseek(modreader,4,SEEK_SET); if(!_mm_read_UBYTES(s,40,modreader)) return NULL; - - return(DupStr(s,40,1)); + + return (DupStr(s,40,1)); } /*========== Loader information */ |