Permalink
Browse files

Fixed strdup free bug

  • Loading branch information...
1 parent b6a4cdd commit c07bd8bb3af3b8a8422eb72de2477649692dbdfe realtech committed Apr 7, 2005
@@ -20,7 +20,7 @@
/*==============================================================================
- $Id: mikmod_internals.h,v 1.2 2005/03/30 19:09:29 realtech Exp $
+ $Id: mikmod_internals.h,v 1.3 2005/04/07 19:57:36 realtech Exp $
MikMod sound library internal definitions
@@ -575,6 +575,7 @@ extern BOOL AllocTracks(void);
extern BOOL AllocInstruments(void);
extern BOOL AllocSamples(void);
extern CHAR* DupStr(CHAR*,UWORD,BOOL);
+extern CHAR* StrDup(CHAR *s);
/* loader utility functions */
extern int* AllocLinear(void);
View
@@ -20,7 +20,7 @@
/*==============================================================================
- $Id: load_669.c,v 1.2 2005/03/30 19:09:29 realtech Exp $
+ $Id: load_669.c,v 1.3 2005/04/07 19:57:38 realtech Exp $
Composer 669 module loader
@@ -280,7 +280,7 @@ BOOL S69_Load(BOOL curious)
of.initspeed=4;
of.inittempo=78;
of.songname=DupStr(mh->message,36,1);
- of.modtype=strdup(S69_Version[memcmp(mh->marker,"JN",2)==0]);
+ of.modtype=StrDup(S69_Version[memcmp(mh->marker,"JN",2)==0]);
of.numchn=8;
of.numpat=mh->nop;
of.numins=of.numsmp=mh->nos;
View
@@ -20,7 +20,7 @@
/*==============================================================================
- $Id: load_amf.c,v 1.2 2005/03/30 19:09:32 realtech Exp $
+ $Id: load_amf.c,v 1.3 2005/04/07 19:57:38 realtech Exp $
DMP Advanced Module Format loader
@@ -384,7 +384,7 @@ BOOL AMF_Load(BOOL curious)
of.inittempo = mh->songbpm;
AMF_Version[AMFTEXTLEN-3]='0'+(mh->version/10);
AMF_Version[AMFTEXTLEN-1]='0'+(mh->version%10);
- of.modtype = strdup(AMF_Version);
+ of.modtype = StrDup(AMF_Version);
of.numchn = mh->numchannels;
of.numtrk = mh->numorders*mh->numchannels;
if (mh->numtracks>of.numtrk)
View
@@ -20,7 +20,7 @@
/*==============================================================================
- $Id: load_asy.c,v 1.2 2005/03/30 19:09:33 realtech Exp $
+ $Id: load_asy.c,v 1.3 2005/04/07 19:57:38 realtech Exp $
ASYLUM Music Format v1.0 (.amf) loader
adapted from load_mod.c by Raphael Assenat <raph@raphnet.net>,
@@ -367,7 +367,7 @@ static BOOL ASY_Load(BOOL curious)
q++;
}
- of.modtype = strdup(descr);
+ of.modtype = StrDup(descr);
if (!ML_LoadPatterns())
return 0;
View
@@ -20,7 +20,7 @@
/*==============================================================================
- $Id: load_dsm.c,v 1.2 2005/03/30 19:09:35 realtech Exp $
+ $Id: load_dsm.c,v 1.3 2005/04/07 19:57:38 realtech Exp $
DSIK internal format (DSM) module loader
@@ -265,7 +265,7 @@ BOOL DSM_Load(BOOL curious)
/* set module variables */
of.initspeed=mh->speed;
of.inittempo=mh->bpm;
- of.modtype=strdup(DSM_Version);
+ of.modtype=StrDup(DSM_Version);
of.numchn=mh->numtrk;
of.numpat=mh->numpat;
of.numtrk=of.numchn*of.numpat;
View
@@ -20,7 +20,7 @@
/*==============================================================================
- $Id: load_far.c,v 1.2 2005/03/30 19:09:35 realtech Exp $
+ $Id: load_far.c,v 1.3 2005/04/07 19:57:38 realtech Exp $
Farandole (FAR) module loader
@@ -195,7 +195,7 @@ BOOL FAR_Load(BOOL curious)
mh1->stlen = _mm_read_I_UWORD (modreader);
/* init modfile data */
- of.modtype = strdup(FAR_Version);
+ of.modtype = StrDup(FAR_Version);
of.songname = DupStr(mh1->songname,40,1);
of.numchn = 16;
of.initspeed = mh1->speed;
View
@@ -20,7 +20,7 @@
/*==============================================================================
- $Id: load_gdm.c,v 1.2 2005/03/30 19:09:35 realtech Exp $
+ $Id: load_gdm.c,v 1.3 2005/04/07 19:57:38 realtech Exp $
General DigiMusic (GDM) module loader
@@ -389,7 +389,7 @@ BOOL GDM_Load(BOOL curious)
}
/* now we fill */
- of.modtype=strdup(GDM_Version);
+ of.modtype=StrDup(GDM_Version);
of.modtype[18]=mh->majorver+'0';
of.modtype[20]=mh->minorver/10+'0';
of.modtype[21]=mh->minorver%10+'0';
View
@@ -20,7 +20,7 @@
/*==============================================================================
- $Id: load_imf.c,v 1.2 2005/03/30 19:09:54 realtech Exp $
+ $Id: load_imf.c,v 1.3 2005/04/07 19:57:38 realtech Exp $
Imago Orpheus (IMF) module loader
@@ -409,7 +409,7 @@ BOOL IMF_Load(BOOL curious)
/* set module variables */
of.songname=DupStr(mh->songname,31,1);
- of.modtype=strdup(IMF_Version);
+ of.modtype=StrDup(IMF_Version);
of.numpat=mh->patnum;
of.numins=mh->insnum;
of.reppos=0;
View
@@ -20,7 +20,7 @@
/*==============================================================================
- $Id: load_it.c,v 1.2 2005/03/30 19:09:58 realtech Exp $
+ $Id: load_it.c,v 1.3 2005/04/07 19:57:38 realtech Exp $
Impulse tracker (IT) module loader
@@ -506,11 +506,11 @@ BOOL IT_Load(BOOL curious)
/* 2.16 : IT 2.14p3 with resonant filters */
/* 2.15 : IT 2.14p3 (improved compression) */
if((mh->cwt<=0x219)&&(mh->cwt>=0x217))
- of.modtype=strdup(IT_Version[mh->cmwt<0x214?4:5]);
+ of.modtype=StrDup(IT_Version[mh->cmwt<0x214?4:5]);
else if (mh->cwt>=0x215)
- of.modtype=strdup(IT_Version[mh->cmwt<0x214?2:3]);
+ of.modtype=StrDup(IT_Version[mh->cmwt<0x214?2:3]);
else {
- of.modtype = strdup(IT_Version[mh->cmwt<0x214?0:1]);
+ of.modtype = StrDup(IT_Version[mh->cmwt<0x214?0:1]);
of.modtype[mh->cmwt<0x214?15:26] = (mh->cwt>>8)+'0';
of.modtype[mh->cmwt<0x214?17:28] = ((mh->cwt>>4)&0xf)+'0';
of.modtype[mh->cmwt<0x214?18:29] = ((mh->cwt)&0xf)+'0';
View
@@ -20,7 +20,7 @@
/*==============================================================================
- $Id: load_m15.c,v 1.2 2005/03/30 19:09:59 realtech Exp $
+ $Id: load_m15.c,v 1.3 2005/04/07 19:57:38 realtech Exp $
15 instrument MOD loader
Also supports Ultimate Sound Tracker (old M15 format)
@@ -408,9 +408,9 @@ static BOOL M15_Load(BOOL curious)
}
if(ust_loader)
- of.modtype = strdup("Ultimate Soundtracker");
+ of.modtype = StrDup("Ultimate Soundtracker");
else
- of.modtype = strdup("Soundtracker");
+ of.modtype = StrDup("Soundtracker");
/* set module variables */
of.initspeed = 6;
View
@@ -20,7 +20,7 @@
/*==============================================================================
- $Id: load_med.c,v 1.2 2005/03/30 19:10:00 realtech Exp $
+ $Id: load_med.c,v 1.3 2005/04/07 19:57:38 realtech Exp $
Amiga MED module loader
@@ -571,7 +571,7 @@ BOOL MED_Load(BOOL curious)
of.flags |= UF_HIGHBPM;
}
MED_Version[12] = mh->id;
- of.modtype = strdup(MED_Version);
+ of.modtype = StrDup(MED_Version);
of.numchn = 0; /* will be counted later */
of.numpat = ms->numblocks;
of.numpos = ms->songlen;
View
@@ -20,7 +20,7 @@
/*==============================================================================
- $Id: load_mod.c,v 1.2 2005/03/30 19:10:02 realtech Exp $
+ $Id: load_mod.c,v 1.3 2005/04/07 19:57:38 realtech Exp $
Generic MOD loader (Protracker, StarTracker, FastTracker, etc)
@@ -476,7 +476,7 @@ static BOOL MOD_Load(BOOL curious)
q++;
}
- of.modtype = strdup(descr);
+ of.modtype = StrDup(descr);
if (!ML_LoadPatterns())
return 0;
View
@@ -20,7 +20,7 @@
/*==============================================================================
- $Id: load_mtm.c,v 1.2 2005/03/30 19:10:02 realtech Exp $
+ $Id: load_mtm.c,v 1.3 2005/04/07 19:57:38 realtech Exp $
MTM module loader
@@ -168,7 +168,7 @@ BOOL MTM_Load(BOOL curious)
/* set module variables */
of.initspeed = 6;
of.inittempo = 125;
- of.modtype = strdup(MTM_Version);
+ of.modtype = StrDup(MTM_Version);
of.numchn = mh->numchannels;
of.numtrk = mh->numtracks+1; /* get number of channels */
of.songname = DupStr(mh->songname,20,1); /* make a cstr of songname */
View
@@ -20,7 +20,7 @@
/*==============================================================================
- $Id: load_okt.c,v 1.2 2005/03/30 19:10:02 realtech Exp $
+ $Id: load_okt.c,v 1.3 2005/04/07 19:57:38 realtech Exp $
Oktalyzer (OKT) module loader
@@ -333,9 +333,9 @@ BOOL OKT_Load(BOOL curious)
/* skip OKTALYZER header */
_mm_fseek(modreader, 8, SEEK_SET);
- of.songname = strdup("");
+ of.songname = StrDup("");
- of.modtype = strdup("Amiga Oktalyzer");
+ of.modtype = StrDup("Amiga Oktalyzer");
of.numpos = of.reppos = 0;
/* default values */
@@ -441,7 +441,7 @@ BOOL OKT_Load(BOOL curious)
CHAR *OKT_LoadTitle(void)
{
- return strdup("");
+ return StrDup("");
}
/*========== Loader information */
View
@@ -20,7 +20,7 @@
/*==============================================================================
- $Id: load_s3m.c,v 1.2 2005/03/30 19:10:02 realtech Exp $
+ $Id: load_s3m.c,v 1.3 2005/04/07 19:57:38 realtech Exp $
Screamtracker (S3M) module loader
@@ -294,7 +294,7 @@ BOOL S3M_Load(BOOL curious)
tracker=NUMTRACKERS; /* IT 2.14p3 */
else tracker--;
}
- of.modtype = strdup(S3M_Version[tracker]);
+ of.modtype = StrDup(S3M_Version[tracker]);
if(tracker<NUMTRACKERS) {
of.modtype[numeric[tracker]] = ((mh->tracker>>8) &0xf)+'0';
of.modtype[numeric[tracker]+2] = ((mh->tracker>>4)&0xf)+'0';
View
@@ -20,7 +20,7 @@
/*==============================================================================
- $Id: load_stm.c,v 1.2 2005/03/30 19:10:04 realtech Exp $
+ $Id: load_stm.c,v 1.3 2005/04/07 19:57:38 realtech Exp $
Screamtracker 2 (STM) module loader
@@ -297,7 +297,7 @@ BOOL STM_Load(BOOL curious)
/* set module variables */
for(t=0;t<STM_NTRACKERS;t++)
if(!memcmp(mh->trackername,STM_Signatures[t],8)) break;
- of.modtype = strdup(STM_Version[t]);
+ of.modtype = StrDup(STM_Version[t]);
of.songname = DupStr(mh->songname,20,1); /* make a cstr of songname */
of.numpat = mh->numpat;
of.inittempo = 125; /* mh->inittempo+0x1c; */
View
@@ -20,7 +20,7 @@
/*==============================================================================
- $Id: load_stx.c,v 1.2 2005/03/30 19:10:06 realtech Exp $
+ $Id: load_stx.c,v 1.3 2005/04/07 19:57:38 realtech Exp $
STMIK 0.2 (STX) module loader
@@ -323,10 +323,10 @@ static BOOL STX_Load(BOOL curious)
version=_mm_read_I_UWORD(modreader);
if(version==mh->patsize) {
version = 0x10;
- of.modtype = strdup("STMIK 0.2 (STM2STX 1.0)");
+ of.modtype = StrDup("STMIK 0.2 (STM2STX 1.0)");
} else {
version = 0x11;
- of.modtype = strdup("STMIK 0.2 (STM2STX 1.1)");
+ of.modtype = StrDup("STMIK 0.2 (STM2STX 1.1)");
}
/* read the order data */
View
@@ -20,7 +20,7 @@
/*==============================================================================
- $Id: load_uni.c,v 1.2 2005/03/30 19:10:07 realtech Exp $
+ $Id: load_uni.c,v 1.3 2005/04/07 19:57:38 realtech Exp $
UNIMOD (libmikmod's and APlayer's internal module format) loader
@@ -591,7 +591,7 @@ BOOL UNI_Load(BOOL curious)
sprintf(modtype,"%s",(universion>=0x100)?"APlayer":"MikCvt3");
#endif
}
- of.modtype=strdup(modtype);
+ of.modtype=StrDup(modtype);
MikMod_free(modtype);MikMod_free(oldtype);
of.comment=readstring();
View
@@ -20,7 +20,7 @@
/*==============================================================================
- $Id: load_xm.c,v 1.2 2005/03/30 19:10:07 realtech Exp $
+ $Id: load_xm.c,v 1.3 2005/04/07 19:57:38 realtech Exp $
Fasttracker (XM) module loader
@@ -697,7 +697,7 @@ BOOL XM_Load(BOOL curious)
sprintf(modtype,"%s (XM format %d.%02d)",
tracker,mh->version>>8,mh->version&0xff);
#endif
- of.modtype = strdup(modtype);
+ of.modtype = StrDup(modtype);
of.numchn = mh->numchn;
of.numpat = mh->numpat;
of.numtrk = (UWORD)of.numpat*of.numchn; /* get number of channels */
View
@@ -20,7 +20,7 @@
/*==============================================================================
- $Id: mloader.c,v 1.2 2005/03/30 19:11:19 realtech Exp $
+ $Id: mloader.c,v 1.3 2005/04/07 19:57:39 realtech Exp $
These routines are used to access the available module loaders
@@ -284,6 +284,14 @@ CHAR *DupStr(CHAR* s,UWORD len,BOOL strict)
return d;
}
+CHAR *StrDup(CHAR *s)
+{
+ size_t l = strlen(s) + 1;
+ CHAR *d = MikMod_malloc(l);
+ strcpy(d, s);
+ return d;
+}
+
static void ML_XFreeSample(SAMPLE *s)
{
if(s->handle>=0)
Oops, something went wrong.

0 comments on commit c07bd8b

Please sign in to comment.