From f68f4beeb751150bfcb8585a83dd56ba7b558db9 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Tue, 27 May 2003 06:38:00 +0000 Subject: [PATCH] fix hang parsing notes high score data --- stepmania/src/SongManager.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/stepmania/src/SongManager.cpp b/stepmania/src/SongManager.cpp index 7f060ee6d4..2f5a11ef7c 100644 --- a/stepmania/src/SongManager.cpp +++ b/stepmania/src/SongManager.cpp @@ -332,7 +332,8 @@ void SongManager::InitMachineScoresFromDisk() Difficulty dc; getline(f, line); - sscanf(line.c_str(), "%d %d", &nt, &dc); + if( sscanf(line.c_str(), "%d %d", &nt, &dc) != 2 ) + break; CString sDescription; getline(f, sDescription); @@ -348,12 +349,16 @@ void SongManager::InitMachineScoresFromDisk() getline(f, line); + int iNumTimesPlayed; + Grade grade; + float fScore; + if( sscanf(line.c_str(), "%d %d %f\n", &iNumTimesPlayed, &grade, &fScore) != 3 ) + break; if( pNotes ) { - sscanf(line.c_str(), "%d %d %f\n", - &pNotes->m_MemCardScores[c].iNumTimesPlayed, - &pNotes->m_MemCardScores[c].grade, - &pNotes->m_MemCardScores[c].fScore); + pNotes->m_MemCardScores[c].iNumTimesPlayed = iNumTimesPlayed; + pNotes->m_MemCardScores[c].grade = grade; + pNotes->m_MemCardScores[c].fScore = fScore; } } }