summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer/modplug
authorerik <erik>2007-02-08 01:45:16 (UTC)
committer erik <erik>2007-02-08 01:45:16 (UTC)
commit2e497f7cae45184184e2416114887095735958f5 (patch) (unidiff)
treea6b399d9bce5854dc7ad6c985b48965cf20680b0 /core/multimedia/opieplayer/modplug
parent853b61f97e718359bef95147ab3c7beb0705acda (diff)
downloadopie-2e497f7cae45184184e2416114887095735958f5.zip
opie-2e497f7cae45184184e2416114887095735958f5.tar.gz
opie-2e497f7cae45184184e2416114887095735958f5.tar.bz2
Each file in this commit has a problem where it is possible to dereference
a pointer without that pointer being valid. This commit fixes each instance of that.
Diffstat (limited to 'core/multimedia/opieplayer/modplug') (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/modplug/sndfile.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/core/multimedia/opieplayer/modplug/sndfile.cpp b/core/multimedia/opieplayer/modplug/sndfile.cpp
index 1d0d610..799555c 100644
--- a/core/multimedia/opieplayer/modplug/sndfile.cpp
+++ b/core/multimedia/opieplayer/modplug/sndfile.cpp
@@ -1694,97 +1694,100 @@ void CSoundFile::FrequencyToTranspose(MODINSTRUMENT *psmp)
1694 int ftune = f2t & 0x7F; 1694 int ftune = f2t & 0x7F;
1695 if (ftune > 80) 1695 if (ftune > 80)
1696 { 1696 {
1697 transp++; 1697 transp++;
1698 ftune -= 128; 1698 ftune -= 128;
1699 } 1699 }
1700 if (transp > 127) transp = 127; 1700 if (transp > 127) transp = 127;
1701 if (transp < -127) transp = -127; 1701 if (transp < -127) transp = -127;
1702 psmp->RelativeTone = transp; 1702 psmp->RelativeTone = transp;
1703 psmp->nFineTune = ftune; 1703 psmp->nFineTune = ftune;
1704} 1704}
1705 1705
1706 1706
1707void CSoundFile::CheckCPUUsage(UINT nCPU) 1707void CSoundFile::CheckCPUUsage(UINT nCPU)
1708//--------------------------------------- 1708//---------------------------------------
1709{ 1709{
1710 if (nCPU > 100) nCPU = 100; 1710 if (nCPU > 100) nCPU = 100;
1711 gnCPUUsage = nCPU; 1711 gnCPUUsage = nCPU;
1712 if (nCPU < 90) 1712 if (nCPU < 90)
1713 { 1713 {
1714 m_dwSongFlags &= ~SONG_CPUVERYHIGH; 1714 m_dwSongFlags &= ~SONG_CPUVERYHIGH;
1715 } else 1715 } else
1716 if ((m_dwSongFlags & SONG_CPUVERYHIGH) && (nCPU >= 94)) 1716 if ((m_dwSongFlags & SONG_CPUVERYHIGH) && (nCPU >= 94))
1717 { 1717 {
1718 UINT i=MAX_CHANNELS; 1718 UINT i=MAX_CHANNELS;
1719 while (i >= 8) 1719 while (i >= 8)
1720 { 1720 {
1721 i--; 1721 i--;
1722 if (Chn[i].nLength) 1722 if (Chn[i].nLength)
1723 { 1723 {
1724 Chn[i].nLength = Chn[i].nPos = 0; 1724 Chn[i].nLength = Chn[i].nPos = 0;
1725 nCPU -= 2; 1725 nCPU -= 2;
1726 if (nCPU < 94) break; 1726 if (nCPU < 94) break;
1727 } 1727 }
1728 } 1728 }
1729 } else 1729 } else
1730 if (nCPU > 90) 1730 if (nCPU > 90)
1731 { 1731 {
1732 m_dwSongFlags |= SONG_CPUVERYHIGH; 1732 m_dwSongFlags |= SONG_CPUVERYHIGH;
1733 } 1733 }
1734} 1734}
1735 1735
1736 1736
1737BOOL CSoundFile::SetPatternName(UINT nPat, LPCSTR lpszName) 1737BOOL CSoundFile::SetPatternName(UINT nPat, LPCSTR lpszName)
1738//--------------------------------------------------------- 1738//---------------------------------------------------------
1739{ 1739{
1740 char szName[MAX_PATTERNNAME] = ""; // changed from CHAR 1740 char szName[MAX_PATTERNNAME] = ""; // changed from CHAR
1741 if (nPat >= MAX_PATTERNS) return FALSE; 1741 if (nPat >= MAX_PATTERNS) return FALSE;
1742 if (lpszName) lstrcpyn(szName, lpszName, MAX_PATTERNNAME); 1742 if (lpszName)
1743 lstrcpyn(szName, lpszName, MAX_PATTERNNAME);
1744 else
1745 return FALSE;
1743 szName[MAX_PATTERNNAME-1] = 0; 1746 szName[MAX_PATTERNNAME-1] = 0;
1744 if (!m_lpszPatternNames) m_nPatternNames = 0; 1747 if (!m_lpszPatternNames) m_nPatternNames = 0;
1745 if (nPat >= m_nPatternNames) 1748 if (nPat >= m_nPatternNames)
1746 { 1749 {
1747 if (!lpszName[0]) return TRUE; 1750 if (!lpszName[0]) return TRUE;
1748 UINT len = (nPat+1)*MAX_PATTERNNAME; 1751 UINT len = (nPat+1)*MAX_PATTERNNAME;
1749 char *p = new char[len]; // changed from CHAR 1752 char *p = new char[len]; // changed from CHAR
1750 if (!p) return FALSE; 1753 if (!p) return FALSE;
1751 memset(p, 0, len); 1754 memset(p, 0, len);
1752 if (m_lpszPatternNames) 1755 if (m_lpszPatternNames)
1753 { 1756 {
1754 memcpy(p, m_lpszPatternNames, m_nPatternNames * MAX_PATTERNNAME); 1757 memcpy(p, m_lpszPatternNames, m_nPatternNames * MAX_PATTERNNAME);
1755 delete m_lpszPatternNames; 1758 delete m_lpszPatternNames;
1756 m_lpszPatternNames = NULL; 1759 m_lpszPatternNames = NULL;
1757 } 1760 }
1758 m_lpszPatternNames = p; 1761 m_lpszPatternNames = p;
1759 m_nPatternNames = nPat + 1; 1762 m_nPatternNames = nPat + 1;
1760 } 1763 }
1761 memcpy(m_lpszPatternNames + nPat * MAX_PATTERNNAME, szName, MAX_PATTERNNAME); 1764 memcpy(m_lpszPatternNames + nPat * MAX_PATTERNNAME, szName, MAX_PATTERNNAME);
1762 return TRUE; 1765 return TRUE;
1763} 1766}
1764 1767
1765 1768
1766BOOL CSoundFile::GetPatternName(UINT nPat, LPSTR lpszName, UINT cbSize) const 1769BOOL CSoundFile::GetPatternName(UINT nPat, LPSTR lpszName, UINT cbSize) const
1767//--------------------------------------------------------------------------- 1770//---------------------------------------------------------------------------
1768{ 1771{
1769 if ((!lpszName) || (!cbSize)) return FALSE; 1772 if ((!lpszName) || (!cbSize)) return FALSE;
1770 lpszName[0] = 0; 1773 lpszName[0] = 0;
1771 if (cbSize > MAX_PATTERNNAME) cbSize = MAX_PATTERNNAME; 1774 if (cbSize > MAX_PATTERNNAME) cbSize = MAX_PATTERNNAME;
1772 if ((m_lpszPatternNames) && (nPat < m_nPatternNames)) 1775 if ((m_lpszPatternNames) && (nPat < m_nPatternNames))
1773 { 1776 {
1774 memcpy(lpszName, m_lpszPatternNames + nPat * MAX_PATTERNNAME, cbSize); 1777 memcpy(lpszName, m_lpszPatternNames + nPat * MAX_PATTERNNAME, cbSize);
1775 lpszName[cbSize-1] = 0; 1778 lpszName[cbSize-1] = 0;
1776 return TRUE; 1779 return TRUE;
1777 } 1780 }
1778 return FALSE; 1781 return FALSE;
1779} 1782}
1780 1783
1781 1784
1782#ifndef FASTSOUNDLIB 1785#ifndef FASTSOUNDLIB
1783 1786
1784UINT CSoundFile::DetectUnusedSamples(BOOL *pbIns) 1787UINT CSoundFile::DetectUnusedSamples(BOOL *pbIns)
1785//----------------------------------------------- 1788//-----------------------------------------------
1786{ 1789{
1787 UINT nExt = 0; 1790 UINT nExt = 0;
1788 1791
1789 if (!pbIns) return 0; 1792 if (!pbIns) return 0;
1790 if (m_nInstruments) 1793 if (m_nInstruments)