From 4259b548b07d4da0ed0234500f90e530454e522d Mon Sep 17 00:00:00 2001 From: Florent Rougon Date: Sat, 15 Apr 2017 09:40:44 +0200 Subject: [PATCH] Fix bugs due to incorrect use of SGPath::pathListSep Before SimGear commit a962c90b30f36575d01162b64471fa77473237a0, SGPath::pathListSep was a char in static memory that was not necessarily followed by '\0'. As a consequence, using &SGPath::pathListSep as a C-style string could result in a string containing the correct separator *plus* whatever followed in memory until the first null byte... SimGear commit a962c90b30 changes this situation by making SGPath::pathListSep an array of two const chars: the path list separator followed by a '\0'. This commit simply adapts FlightGear to this change, which fixes a couple of bugs where the separator was used, mainly unneeded NavCache rebuilds due to the "apt.dat", "fix.dat" and "nav.dat" properties in the SQLite database containing the correct paths separated by a possibly incorrect separator string (there was no alteration of the cache contents as far as I can tell, since the db property is only used to check if the lists of apt.dat, fix.dat and nav.dat files have changed). --- src/Main/options.cxx | 2 +- src/Navaids/NavDataCache.cxx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Main/options.cxx b/src/Main/options.cxx index c62f7baca..4f3120f90 100644 --- a/src/Main/options.cxx +++ b/src/Main/options.cxx @@ -2671,7 +2671,7 @@ void Options::showVersion() const cout << "FG_SCENERY="; PathList scn = globals->get_fg_scenery(); - cout << SGPath::join(scn, &SGPath::pathListSep) << endl; + cout << SGPath::join(scn, SGPath::pathListSep) << endl; cout << "SimGear version: " << SG_STRINGIZE(SIMGEAR_VERSION) << endl; #ifndef FG_TESTLIB cout << "OSG version: " << osgGetVersion() << endl; diff --git a/src/Navaids/NavDataCache.cxx b/src/Navaids/NavDataCache.cxx index fd7acd54d..ba2a77f1d 100644 --- a/src/Navaids/NavDataCache.cxx +++ b/src/Navaids/NavDataCache.cxx @@ -1114,7 +1114,7 @@ bool NavDataCache::NavDataCachePrivate::areDatFilesModified( const string datTypeStr = NavDataCache::datTypeStr[datFileType]; const string_list cachedFiles = outer->readOrderedStringListProperty( - datTypeStr + ".dat files", &SGPath::pathListSep); + datTypeStr + ".dat files", SGPath::pathListSep); const PathList& datFiles = datFilesGroupInfo.paths; PathList::const_iterator datFilesIt = datFiles.begin(); string_list::const_iterator cachedFilesIt = cachedFiles.begin(); @@ -1406,7 +1406,7 @@ void NavDataCache::loadDatFiles( // Store the list of .dat files we have loaded writeOrderedStringListProperty(typeStr + ".dat files", datFiles, - &SGPath::pathListSep); + SGPath::pathListSep); SG_LOG(SG_NAVCACHE, SG_INFO, typeStr + ".dat files load took: " << st.elapsedMSec());