Skip to content

Commit 18d9eb1

Browse files
Recorder: Ensure m_crcInfo is deleted in destructor and reset functions
1 parent fa74ece commit 18d9eb1

2 files changed

Lines changed: 54 additions & 0 deletions

File tree

Generals/Code/GameEngine/Source/Common/Recorder.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,7 @@ RecorderClass::RecorderClass()
372372
m_archiveReplays = FALSE;
373373
m_nextFrame = 0;
374374
m_wasDesync = FALSE;
375+
m_crcInfo = NULL;
375376
//
376377

377378
init(); // just for the heck of it.
@@ -381,6 +382,10 @@ RecorderClass::RecorderClass()
381382
* Destructor
382383
*/
383384
RecorderClass::~RecorderClass() {
385+
if (m_crcInfo != NULL) {
386+
deleteInstance(m_crcInfo);
387+
m_crcInfo = NULL;
388+
}
384389
}
385390

386391
/**
@@ -407,6 +412,11 @@ void RecorderClass::init() {
407412
m_doingAnalysis = FALSE;
408413
m_playbackFrameCount = 0;
409414

415+
if (m_crcInfo != NULL) {
416+
deleteInstance(m_crcInfo);
417+
m_crcInfo = NULL;
418+
}
419+
410420
OptionPreferences optionPref;
411421
m_archiveReplays = optionPref.getArchiveReplaysEnabled();
412422
}
@@ -421,6 +431,11 @@ void RecorderClass::reset() {
421431
}
422432
m_fileName.clear();
423433

434+
if (m_crcInfo != NULL) {
435+
deleteInstance(m_crcInfo);
436+
m_crcInfo = NULL;
437+
}
438+
424439
init();
425440
}
426441

@@ -478,6 +493,11 @@ void RecorderClass::stopPlayback() {
478493
}
479494
m_fileName.clear();
480495

496+
if (m_crcInfo != NULL) {
497+
deleteInstance(m_crcInfo);
498+
m_crcInfo = NULL;
499+
}
500+
481501
if (!m_doingAnalysis)
482502
{
483503
TheMessageStream->appendMessage(GameMessage::MSG_CLEAR_GAME_DATA);
@@ -1058,11 +1078,18 @@ UnsignedInt CRCInfo::readCRC(void)
10581078

10591079
Bool RecorderClass::sawCRCMismatch() const
10601080
{
1081+
if (m_crcInfo == NULL) {
1082+
return FALSE;
1083+
}
10611084
return m_crcInfo->sawCRCMismatch();
10621085
}
10631086

10641087
void RecorderClass::handleCRCMessage(UnsignedInt newCRC, Int playerIndex, Bool fromPlayback)
10651088
{
1089+
if (m_crcInfo == NULL) {
1090+
return;
1091+
}
1092+
10661093
if (fromPlayback)
10671094
{
10681095
//DEBUG_LOG(("RecorderClass::handleCRCMessage() - Adding CRC of %X from %d to m_crcInfo", newCRC, playerIndex));

GeneralsMD/Code/GameEngine/Source/Common/Recorder.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ RecorderClass::RecorderClass()
378378
m_archiveReplays = FALSE;
379379
m_nextFrame = 0;
380380
m_wasDesync = FALSE;
381+
m_crcInfo = NULL;
381382
//
382383

383384
init(); // just for the heck of it.
@@ -387,6 +388,10 @@ RecorderClass::RecorderClass()
387388
* Destructor
388389
*/
389390
RecorderClass::~RecorderClass() {
391+
if (m_crcInfo != NULL) {
392+
deleteInstance(m_crcInfo);
393+
m_crcInfo = NULL;
394+
}
390395
}
391396

392397
/**
@@ -413,6 +418,11 @@ void RecorderClass::init() {
413418
m_doingAnalysis = FALSE;
414419
m_playbackFrameCount = 0;
415420

421+
if (m_crcInfo != NULL) {
422+
deleteInstance(m_crcInfo);
423+
m_crcInfo = NULL;
424+
}
425+
416426
OptionPreferences optionPref;
417427
m_archiveReplays = optionPref.getArchiveReplaysEnabled();
418428
}
@@ -427,6 +437,11 @@ void RecorderClass::reset() {
427437
}
428438
m_fileName.clear();
429439

440+
if (m_crcInfo != NULL) {
441+
deleteInstance(m_crcInfo);
442+
m_crcInfo = NULL;
443+
}
444+
430445
init();
431446
}
432447

@@ -485,6 +500,11 @@ void RecorderClass::stopPlayback() {
485500
}
486501
m_fileName.clear();
487502

503+
if (m_crcInfo != NULL) {
504+
deleteInstance(m_crcInfo);
505+
m_crcInfo = NULL;
506+
}
507+
488508
if (!m_doingAnalysis)
489509
{
490510
TheGameLogic->exitGame();
@@ -1112,11 +1132,18 @@ UnsignedInt CRCInfo::readCRC(void)
11121132

11131133
Bool RecorderClass::sawCRCMismatch() const
11141134
{
1135+
if (m_crcInfo == NULL) {
1136+
return FALSE;
1137+
}
11151138
return m_crcInfo->sawCRCMismatch();
11161139
}
11171140

11181141
void RecorderClass::handleCRCMessage(UnsignedInt newCRC, Int playerIndex, Bool fromPlayback)
11191142
{
1143+
if (m_crcInfo == NULL) {
1144+
return;
1145+
}
1146+
11201147
if (fromPlayback)
11211148
{
11221149
//DEBUG_LOG(("RecorderClass::handleCRCMessage() - Adding CRC of %X from %d to m_crcInfo", newCRC, playerIndex));

0 commit comments

Comments
 (0)