From 74516bbe6211d5d8f860c4820e8c8ab1e9679b53 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Mon, 2 Apr 2018 03:38:08 -0300 Subject: [PATCH] Fix possible division by 0 defect --- src/ScoreKeeperNormal.cpp | 4 ++-- src/XMLProfile.cpp | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ScoreKeeperNormal.cpp b/src/ScoreKeeperNormal.cpp index 861d5324a7..45396667c9 100644 --- a/src/ScoreKeeperNormal.cpp +++ b/src/ScoreKeeperNormal.cpp @@ -391,7 +391,7 @@ void ScoreKeeperNormal::HandleTapNoteScoreInternal( const NoteData &nd, TapNoteS { if (separately) { - m_pPlayerStageStats->m_iActualDancePoints += (TapNoteScoreToDancePoints(tns)*nd.GetNumTracksLCD()) / notes; + m_pPlayerStageStats->m_iActualDancePoints += notes != 0 ? (TapNoteScoreToDancePoints(tns)*nd.GetNumTracksLCD()) / notes : 0; } else { @@ -402,7 +402,7 @@ void ScoreKeeperNormal::HandleTapNoteScoreInternal( const NoteData &nd, TapNoteS // increment the current total possible dance score if (separately) { - m_pPlayerStageStats->m_iCurPossibleDancePoints += (TapNoteScoreToDancePoints(maximum)*nd.GetNumTracksLCD()) / notes; + m_pPlayerStageStats->m_iCurPossibleDancePoints += notes != 0 ? (TapNoteScoreToDancePoints(maximum)*nd.GetNumTracksLCD()) / notes : 0; } else { diff --git a/src/XMLProfile.cpp b/src/XMLProfile.cpp index bcbb2d3a93..937287d4ca 100644 --- a/src/XMLProfile.cpp +++ b/src/XMLProfile.cpp @@ -613,7 +613,8 @@ void XMLProfile::LoadStatsXmlForConversion() { return; XNode* scores = xml.GetChild("SongScores"); - LoadSongScoresFromNode(scores); + if (scores != nullptr) + LoadSongScoresFromNode(scores); }