From bfa1f392f744592ed24934a8900b5612f5886093 Mon Sep 17 00:00:00 2001 From: Thierry Crozat Date: Sun, 14 Jul 2019 22:09:34 +0100 Subject: POSIX: Fix missing expansion of "~" to home when it has no suffix This fixes bug #10941: Tilde in save path creates "~" folder --- backends/fs/posix/posix-fs.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/backends/fs/posix/posix-fs.cpp b/backends/fs/posix/posix-fs.cpp index c99505cc4d..5b724c291f 100644 --- a/backends/fs/posix/posix-fs.cpp +++ b/backends/fs/posix/posix-fs.cpp @@ -91,13 +91,13 @@ POSIXFilesystemNode::POSIXFilesystemNode(const Common::String &p) { #endif // Expand "~/" to the value of the HOME env variable - if (p.hasPrefix("~/")) { + if (p.hasPrefix("~/") || p == "~") { const char *home = getenv("HOME"); if (home != NULL && strlen(home) < MAXPATHLEN) { _path = home; - // Skip over the tilda. We know that p contains at least - // two chars, so this is safe: - _path += p.c_str() + 1; + // Skip over the tilda. + if (p.size() > 1) + _path += p.c_str() + 1; } } else { _path = p; -- cgit v1.2.3