add missing copy ctor (fixes potential crash; reproduced in a test case but may not actually manifest anywhere)

This commit is contained in:
Glenn Maynard
2005-05-05 00:17:19 +00:00
parent abbfc6ad7b
commit 954b1721e6
2 changed files with 23 additions and 0 deletions
+22
View File
@@ -15,6 +15,28 @@ RageFileObj::RageFileObj()
m_iCRC32 = 0;
}
RageFileObj::RageFileObj( const RageFileObj &cpy ):
RageFileBasic(cpy)
{
/* If the original file has a buffer, copy it. */
if( cpy.m_pBuffer != NULL )
{
m_pBuffer = new char[BSIZE];
memcpy( m_pBuffer, cpy.m_pBuffer, BSIZE );
int iOffsetIntoBuffer = cpy.m_pBuf - cpy.m_pBuffer;
m_pBuf = m_pBuffer + iOffsetIntoBuffer;
}
else
m_pBuffer = NULL;
m_iBufAvail = cpy.m_iBufAvail;
m_bEOF = cpy.m_bEOF;
m_iFilePos = cpy.m_iFilePos;
m_bCRC32Enabled = cpy.m_bCRC32Enabled;
m_iCRC32 = cpy.m_iCRC32;
}
RageFileObj::~RageFileObj()
{
delete [] m_pBuffer;
+1
View File
@@ -59,6 +59,7 @@ class RageFileObj: public RageFileBasic
{
public:
RageFileObj();
RageFileObj( const RageFileObj &cpy );
virtual ~RageFileObj();
virtual CString GetError() const { return m_sError; }