From 4130874a41dd78dced49e1b50110262b81b1e45e Mon Sep 17 00:00:00 2001 From: Steve Checkoway Date: Sat, 8 Jul 2006 06:07:54 +0000 Subject: [PATCH] Disallow nonpositive tick counts and negative difficulties. (I'm not sure if the latter should be positive or merely nonnegative.) --- stepmania/src/NotesLoaderKSF.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/stepmania/src/NotesLoaderKSF.cpp b/stepmania/src/NotesLoaderKSF.cpp index ae5dbc39a4..0f68cd8122 100644 --- a/stepmania/src/NotesLoaderKSF.cpp +++ b/stepmania/src/NotesLoaderKSF.cpp @@ -79,16 +79,22 @@ bool KSFLoader::LoadFromKSFFile( const RString &sPath, Steps &out, const Song &s if( 0==stricmp(sValueName,"TICKCOUNT") ) { iTickCount = atoi( sParams[1] ); + if( iTickCount <= 0 ) + { + // XXX need a place for user warnings. + LOG->Warn( "Invalid tick count: %d", iTickCount ); + return false; + } } else if( 0==stricmp(sValueName,"STEP") ) { RString step = sParams[1]; - TrimLeft(step); + TrimLeft( step ); split( step, "\n", asRows, true ); } else if( 0==stricmp(sValueName,"DIFFICULTY") ) { - out.SetMeter( atoi(sParams[1]) ); + out.SetMeter( max(atoi(sParams[1]), 0) ); } }