From fd2fd9719aa186979e184b70b94408f0e81f8efe Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Wed, 21 Jan 2004 03:33:39 +0000 Subject: [PATCH] fix uninitialized variables --- stepmania/src/SongCacheIndex.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/stepmania/src/SongCacheIndex.cpp b/stepmania/src/SongCacheIndex.cpp index a5e93d3f24..8b68de1811 100644 --- a/stepmania/src/SongCacheIndex.cpp +++ b/stepmania/src/SongCacheIndex.cpp @@ -55,7 +55,7 @@ void SongCacheIndex::ReadCacheIndex() { CacheIndex.ReadFile(); // don't care if this fails - int iCacheVersion; + int iCacheVersion = -1; CacheIndex.GetValue( "Cache", "CacheVersion", iCacheVersion ); if( iCacheVersion == FILE_CACHE_VERSION ) return; /* OK */ @@ -70,6 +70,8 @@ void SongCacheIndex::ReadCacheIndex() void SongCacheIndex::AddCacheIndex(const CString &path, unsigned hash) { + if( hash == 0 ) + ++hash; /* no 0 hash values */ CacheIndex.SetValue( "Cache", "CacheVersion", FILE_CACHE_VERSION ); CacheIndex.SetValue( "Cache", MangleName(path), hash ); CacheIndex.WriteFile(); @@ -78,7 +80,10 @@ void SongCacheIndex::AddCacheIndex(const CString &path, unsigned hash) unsigned SongCacheIndex::GetCacheHash( const CString &path ) const { unsigned iDirHash; - CacheIndex.GetValue( "Cache", MangleName(path), iDirHash ); + if( !CacheIndex.GetValue( "Cache", MangleName(path), iDirHash ) ) + return 0; + if( iDirHash == 0 ) + ++iDirHash; /* no 0 hash values */ return iDirHash; }