summaryrefslogtreecommitdiff
authorerik <erik>2007-01-31 22:21:38 (UTC)
committer erik <erik>2007-01-31 22:21:38 (UTC)
commited5fba8cdb27174427b2e7780508bafa05536ca1 (patch) (side-by-side diff)
tree9dca5bd75617c8f18ba066bbd90ef88dc2473d84
parent9395cf2a65184e493714c699bb23b02ea31feef5 (diff)
downloadopie-ed5fba8cdb27174427b2e7780508bafa05536ca1.zip
opie-ed5fba8cdb27174427b2e7780508bafa05536ca1.tar.gz
opie-ed5fba8cdb27174427b2e7780508bafa05536ca1.tar.bz2
A few files that have dynamically allocated arrays that are not properly
de-allocated (forgot to use []).
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/modplug/load_amf.cpp2
-rw-r--r--core/multimedia/opieplayer/modplug/load_ams.cpp2
-rw-r--r--core/multimedia/opieplayer/modplug/load_mdl.cpp2
3 files changed, 3 insertions, 3 deletions
diff --git a/core/multimedia/opieplayer/modplug/load_amf.cpp b/core/multimedia/opieplayer/modplug/load_amf.cpp
index 188b5f5..2cf131b 100644
--- a/core/multimedia/opieplayer/modplug/load_amf.cpp
+++ b/core/multimedia/opieplayer/modplug/load_amf.cpp
@@ -309,112 +309,112 @@ BOOL CSoundFile::ReadAMF(LPCBYTE lpStream, DWORD dwMemLength)
// Setup sequence list
for (UINT iOrd=0; iOrd<MAX_ORDERS; iOrd++)
{
Order[iOrd] = 0xFF;
if (iOrd < pfh->numorders)
{
Order[iOrd] = iOrd;
PatternSize[iOrd] = 64;
if (pfh->version >= 14)
{
PatternSize[iOrd] = *(USHORT *)(lpStream+dwMemPos);
dwMemPos += 2;
}
ptracks[iOrd] = (USHORT *)(lpStream+dwMemPos);
dwMemPos += m_nChannels * sizeof(USHORT);
}
}
if (dwMemPos + m_nSamples * (sizeof(AMFSAMPLE)+8) > dwMemLength) return TRUE;
// Read Samples
UINT maxsampleseekpos = 0;
for (UINT iIns=0; iIns<m_nSamples; iIns++)
{
MODINSTRUMENT *pins = &Ins[iIns+1];
AMFSAMPLE *psh = (AMFSAMPLE *)(lpStream + dwMemPos);
dwMemPos += sizeof(AMFSAMPLE);
memcpy(m_szNames[iIns+1], psh->samplename, 32);
memcpy(pins->name, psh->filename, 13);
pins->nLength = psh->length;
pins->nC4Speed = psh->c2spd;
pins->nGlobalVol = 64;
pins->nVolume = psh->volume * 4;
if (pfh->version >= 11)
{
pins->nLoopStart = *(DWORD *)(lpStream+dwMemPos);
pins->nLoopEnd = *(DWORD *)(lpStream+dwMemPos+4);
dwMemPos += 8;
} else
{
pins->nLoopStart = *(WORD *)(lpStream+dwMemPos);
pins->nLoopEnd = pins->nLength;
dwMemPos += 2;
}
sampleseekpos[iIns] = 0;
if ((psh->type) && (psh->offset < dwMemLength-1))
{
sampleseekpos[iIns] = psh->offset;
if (psh->offset > maxsampleseekpos) maxsampleseekpos = psh->offset;
if ((pins->nLoopEnd > pins->nLoopStart + 2)
&& (pins->nLoopEnd <= pins->nLength)) pins->uFlags |= CHN_LOOP;
}
}
// Read Track Mapping Table
USHORT *pTrackMap = (USHORT *)(lpStream+dwMemPos);
UINT realtrackcnt = 0;
dwMemPos += pfh->numtracks * sizeof(USHORT);
for (UINT iTrkMap=0; iTrkMap<pfh->numtracks; iTrkMap++)
{
if (realtrackcnt < pTrackMap[iTrkMap]) realtrackcnt = pTrackMap[iTrkMap];
}
// Store tracks positions
BYTE **pTrackData = new BYTE *[realtrackcnt];
memset(pTrackData, 0, sizeof(pTrackData));
for (UINT iTrack=0; iTrack<realtrackcnt; iTrack++) if (dwMemPos + 3 <= dwMemLength)
{
UINT nTrkSize = *(USHORT *)(lpStream+dwMemPos);
nTrkSize += (UINT)lpStream[dwMemPos+2] << 16;
if (dwMemPos + nTrkSize * 3 + 3 <= dwMemLength)
{
pTrackData[iTrack] = (BYTE *)(lpStream + dwMemPos);
}
dwMemPos += nTrkSize * 3 + 3;
}
// Create the patterns from the list of tracks
for (UINT iPat=0; iPat<pfh->numorders; iPat++)
{
MODCOMMAND *p = AllocatePattern(PatternSize[iPat], m_nChannels);
if (!p) break;
Patterns[iPat] = p;
for (UINT iChn=0; iChn<m_nChannels; iChn++)
{
UINT nTrack = ptracks[iPat][iChn];
if ((nTrack) && (nTrack <= pfh->numtracks))
{
UINT realtrk = pTrackMap[nTrack-1];
if (realtrk)
{
realtrk--;
if ((realtrk < realtrackcnt) && (pTrackData[realtrk]))
{
AMF_Unpack(p+iChn, pTrackData[realtrk], PatternSize[iPat], m_nChannels);
}
}
}
}
}
- delete pTrackData;
+ delete [] pTrackData;
// Read Sample Data
for (UINT iSeek=1; iSeek<=maxsampleseekpos; iSeek++)
{
if (dwMemPos >= dwMemLength) break;
for (UINT iSmp=0; iSmp<m_nSamples; iSmp++) if (iSeek == sampleseekpos[iSmp])
{
MODINSTRUMENT *pins = &Ins[iSmp+1];
dwMemPos += ReadSample(pins, RS_PCM8U, (LPCSTR)(lpStream+dwMemPos), dwMemLength-dwMemPos);
break;
}
}
return TRUE;
}
diff --git a/core/multimedia/opieplayer/modplug/load_ams.cpp b/core/multimedia/opieplayer/modplug/load_ams.cpp
index 3dd1c2b..ad1cc01 100644
--- a/core/multimedia/opieplayer/modplug/load_ams.cpp
+++ b/core/multimedia/opieplayer/modplug/load_ams.cpp
@@ -533,99 +533,99 @@ BOOL CSoundFile::ReadAMS2(LPCBYTE lpStream, DWORD dwMemLength)
} else
{
// TODO: AMS effects
}
}
}
}
if (byte1 & 0x80) row++;
}
}
dwMemPos += packedlen;
}
// Read Samples
for (UINT iSmp=1; iSmp<=m_nSamples; iSmp++) if (Ins[iSmp].nLength)
{
if (dwMemPos >= dwMemLength - 9) return TRUE;
UINT flags;
if (packedsamples[iSmp] & 0x03)
{
flags = (Ins[iSmp].uFlags & CHN_16BIT) ? RS_AMS16 : RS_AMS8;
} else
{
flags = (Ins[iSmp].uFlags & CHN_16BIT) ? RS_PCM16S : RS_PCM8S;
}
dwMemPos += ReadSample(&Ins[iSmp], flags, (LPSTR)(lpStream+dwMemPos), dwMemLength-dwMemPos);
}
return TRUE;
}
/////////////////////////////////////////////////////////////////////
// AMS Sample unpacking
void AMSUnpack(const char *psrc, UINT inputlen, char *pdest, UINT dmax, char packcharacter)
{
UINT tmplen = dmax;
signed char *amstmp = new signed char[tmplen];
if (!amstmp) return;
// Unpack Loop
{
signed char *p = amstmp;
UINT i=0, j=0;
while ((i < inputlen) && (j < tmplen))
{
signed char ch = psrc[i++];
if (ch == packcharacter)
{
BYTE ch2 = psrc[i++];
if (ch2)
{
ch = psrc[i++];
while (ch2--)
{
p[j++] = ch;
if (j >= tmplen) break;
}
} else p[j++] = packcharacter;
} else p[j++] = ch;
}
}
// Bit Unpack Loop
{
signed char *p = amstmp;
UINT bitcount = 0x80, dh;
UINT k=0;
for (UINT i=0; i<dmax; i++)
{
BYTE al = *p++;
dh = 0;
for (UINT count=0; count<8; count++)
{
UINT bl = al & bitcount;
bl = ((bl|(bl<<8)) >> ((dh+8-count) & 7)) & 0xFF;
bitcount = ((bitcount|(bitcount<<8)) >> 1) & 0xFF;
pdest[k++] |= bl;
if (k >= dmax)
{
k = 0;
dh++;
}
}
bitcount = ((bitcount|(bitcount<<8)) >> dh) & 0xFF;
}
}
// Delta Unpack
{
signed char old = 0;
for (UINT i=0; i<dmax; i++)
{
int pos = ((LPBYTE)pdest)[i];
if ((pos != 128) && (pos & 0x80)) pos = -(pos & 0x7F);
old -= (signed char)pos;
pdest[i] = old;
}
}
- delete amstmp;
+ delete [] amstmp;
}
diff --git a/core/multimedia/opieplayer/modplug/load_mdl.cpp b/core/multimedia/opieplayer/modplug/load_mdl.cpp
index 806b68b..e1f78d5 100644
--- a/core/multimedia/opieplayer/modplug/load_mdl.cpp
+++ b/core/multimedia/opieplayer/modplug/load_mdl.cpp
@@ -152,193 +152,193 @@ void UnpackMDLTrack(MODCOMMAND *pat, UINT nChannels, UINT nRows, UINT nTrack, co
command1 = 0xEF;
command2 = param2 = 0;
}
if (volume)
{
cmd.volcmd = VOLCMD_VOLUME;
cmd.vol = (volume+1) >> 2;
}
ConvertMDLCommand(&cmd, command1, param1);
if ((cmd.command != CMD_SPEED)
&& (cmd.command != CMD_TEMPO)
&& (cmd.command != CMD_PATTERNBREAK))
ConvertMDLCommand(&cmd, command2, param2);
*m = cmd;
m += nChannels;
row++;
}
break;
// Empty Slots
default:
row += xx+1;
m += (xx+1)*nChannels;
if (row >= nRows) break;
}
}
}
BOOL CSoundFile::ReadMDL(const BYTE *lpStream, DWORD dwMemLength)
//---------------------------------------------------------------
{
DWORD dwMemPos, dwPos, blocklen, dwTrackPos;
const MDLSONGHEADER *pmsh = (const MDLSONGHEADER *)lpStream;
MDLINFOBLOCK *pmib;
MDLPATTERNDATA *pmpd;
UINT i,j, norders = 0, npatterns = 0, ntracks = 0;
UINT ninstruments = 0, nsamples = 0;
WORD block;
WORD patterntracks[MAX_PATTERNS*32];
BYTE smpinfo[MAX_SAMPLES];
BYTE insvolenv[MAX_INSTRUMENTS];
BYTE inspanenv[MAX_INSTRUMENTS];
LPCBYTE pvolenv, ppanenv, ppitchenv;
UINT nvolenv, npanenv, npitchenv;
if ((!lpStream) || (dwMemLength < 1024)) return FALSE;
if ((pmsh->id != 0x4C444D44) || ((pmsh->version & 0xF0) > 0x10)) return FALSE;
memset(patterntracks, 0, sizeof(patterntracks));
memset(smpinfo, 0, sizeof(smpinfo));
memset(insvolenv, 0, sizeof(insvolenv));
memset(inspanenv, 0, sizeof(inspanenv));
dwMemPos = 5;
dwTrackPos = 0;
pvolenv = ppanenv = ppitchenv = NULL;
nvolenv = npanenv = npitchenv = 0;
m_nSamples = m_nInstruments = 0;
while (dwMemPos+6 < dwMemLength)
{
block = *((WORD *)(lpStream+dwMemPos));
blocklen = *((DWORD *)(lpStream+dwMemPos+2));
dwMemPos += 6;
if (dwMemPos + blocklen > dwMemLength)
{
if (dwMemPos == 11) return FALSE;
break;
}
switch(block)
{
// IN: infoblock
case 0x4E49:
pmib = (MDLINFOBLOCK *)(lpStream+dwMemPos);
memcpy(m_szNames[0], pmib->songname, 32);
norders = pmib->norders;
if (norders > MAX_ORDERS) norders = MAX_ORDERS;
m_nRestartPos = pmib->repeatpos;
m_nDefaultGlobalVolume = pmib->globalvol;
m_nDefaultTempo = pmib->tempo;
m_nDefaultSpeed = pmib->speed;
m_nChannels = 4;
for (i=0; i<32; i++)
{
ChnSettings[i].nVolume = 64;
ChnSettings[i].nPan = (pmib->channelinfo[i] & 0x7F) << 1;
if (pmib->channelinfo[i] & 0x80)
ChnSettings[i].dwFlags |= CHN_MUTE;
else
m_nChannels = i+1;
}
for (j=0; j<norders; j++) Order[j] = pmib->seq[j];
break;
// ME: song message
case 0x454D:
if (blocklen)
{
- if (m_lpszSongComments) delete m_lpszSongComments;
+ if (m_lpszSongComments) delete [] m_lpszSongComments;
m_lpszSongComments = new char[blocklen];
if (m_lpszSongComments)
{
memcpy(m_lpszSongComments, lpStream+dwMemPos, blocklen);
m_lpszSongComments[blocklen-1] = 0;
}
}
break;
// PA: Pattern Data
case 0x4150:
npatterns = lpStream[dwMemPos];
if (npatterns > MAX_PATTERNS) npatterns = MAX_PATTERNS;
dwPos = dwMemPos + 1;
for (i=0; i<npatterns; i++)
{
if (dwPos+18 >= dwMemLength) break;
pmpd = (MDLPATTERNDATA *)(lpStream + dwPos);
if (pmpd->channels > 32) break;
PatternSize[i] = pmpd->lastrow+1;
if (m_nChannels < pmpd->channels) m_nChannels = pmpd->channels;
dwPos += 18 + 2*pmpd->channels;
for (j=0; j<pmpd->channels; j++)
{
patterntracks[i*32+j] = pmpd->data[j];
}
}
break;
// TR: Track Data
case 0x5254:
if (dwTrackPos) break;
ntracks = *((WORD *)(lpStream+dwMemPos));
dwTrackPos = dwMemPos+2;
break;
// II: Instruments
case 0x4949:
ninstruments = lpStream[dwMemPos];
dwPos = dwMemPos+1;
for (i=0; i<ninstruments; i++)
{
UINT nins = lpStream[dwPos];
if ((nins >= MAX_INSTRUMENTS) || (!nins)) break;
if (m_nInstruments < nins) m_nInstruments = nins;
if (!Headers[nins])
{
UINT note = 12;
if ((Headers[nins] = new INSTRUMENTHEADER) == NULL) break;
INSTRUMENTHEADER *penv = Headers[nins];
memset(penv, 0, sizeof(INSTRUMENTHEADER));
memcpy(penv->name, lpStream+dwPos+2, 32);
penv->nGlobalVol = 64;
penv->nPPC = 5*12;
for (j=0; j<lpStream[dwPos+1]; j++)
{
const BYTE *ps = lpStream+dwPos+34+14*j;
while ((note < (UINT)(ps[1]+12)) && (note < 120))
{
penv->NoteMap[note] = note+1;
if (ps[0] < MAX_SAMPLES)
{
int ismp = ps[0];
penv->Keyboard[note] = ps[0];
Ins[ismp].nVolume = ps[2];
Ins[ismp].nPan = ps[4] << 1;
Ins[ismp].nVibType = ps[11];
Ins[ismp].nVibSweep = ps[10];
Ins[ismp].nVibDepth = ps[9];
Ins[ismp].nVibRate = ps[8];
}
penv->nFadeOut = (ps[7] << 8) | ps[6];
if (penv->nFadeOut == 0xFFFF) penv->nFadeOut = 0;
note++;
}
// Use volume envelope ?
if (ps[3] & 0x80)
{
penv->dwFlags |= ENV_VOLUME;
insvolenv[nins] = (ps[3] & 0x3F) + 1;
}
// Use panning envelope ?
if (ps[5] & 0x80)
{
penv->dwFlags |= ENV_PANNING;
inspanenv[nins] = (ps[5] & 0x3F) + 1;
}
}
}
dwPos += 34 + 14*lpStream[dwPos+1];
}
for (j=1; j<=m_nInstruments; j++) if (!Headers[j])
{
Headers[j] = new INSTRUMENTHEADER;
if (Headers[j]) memset(Headers[j], 0, sizeof(INSTRUMENTHEADER));
}
break;
// VE: Volume Envelope
case 0x4556: