Attempt to fix realpath() recursion

Sentry-Id: FLIGHTGEAR-D6W
This commit is contained in:
James Turner 2021-06-14 13:52:22 +01:00 committed by Automatic Release Builder
parent e6f4936536
commit 71e7050349

View File

@ -48,6 +48,7 @@
#endif #endif
#include "sg_path.hxx" #include "sg_path.hxx"
#include <simgear/misc/sg_dir.hxx>
using std::string; using std::string;
using simgear::strutils::starts_with; using simgear::strutils::starts_with;
@ -995,8 +996,9 @@ SGPath SGPath::realpath() const
// (needed for fgValidatePath security) // (needed for fgValidatePath security)
{ {
if (path.empty()) { if (path.empty()) {
return SGPath(".").realpath(); // current directory return simgear::Dir::current().path();
} }
std::string this_dir = dir(); std::string this_dir = dir();
if (isAbsolute() && this_dir.empty()) { // top level if (isAbsolute() && this_dir.empty()) { // top level
this_dir = "/"; this_dir = "/";