From 8fe6c209f8a7e1a536793300e086af17064aef6b Mon Sep 17 00:00:00 2001 From: baldurk Date: Thu, 4 May 2023 17:28:01 +0100 Subject: [PATCH] Fix infinite recursion on android getting environment variables * We changed all uses of getenv to our Process::GetEnvironmentVariable in a1422df, but on android this causes an infinite recursion because its implementation of GetEnvironmentVariable uses LaunchProcess to query for the variable, which then tries to look up the PATH variable (which does not exist on android). --- renderdoc/os/posix/android/android_stringio.cpp | 5 +++++ renderdoc/os/posix/apple/apple_stringio.cpp | 6 ++++++ renderdoc/os/posix/ggp/ggp_stringio.cpp | 6 ++++++ renderdoc/os/posix/linux/linux_stringio.cpp | 6 ++++++ renderdoc/os/posix/posix_stringio.cpp | 2 +- 5 files changed, 24 insertions(+), 1 deletion(-) diff --git a/renderdoc/os/posix/android/android_stringio.cpp b/renderdoc/os/posix/android/android_stringio.cpp index 071d21add..fa9cb9045 100644 --- a/renderdoc/os/posix/android/android_stringio.cpp +++ b/renderdoc/os/posix/android/android_stringio.cpp @@ -85,6 +85,11 @@ rdcstr GetAppFolderFilename(const rdcstr &filename) return GetTempRootPath() + rdcstr("/") + filename; } +rdcstr FindFileInPath(const rdcstr &fileName) +{ + return fileName; +} + // For RenderDoc's apk, this returns our package name // For other APKs, we use it to get the writable temp directory. void GetExecutableFilename(rdcstr &selfName) diff --git a/renderdoc/os/posix/apple/apple_stringio.cpp b/renderdoc/os/posix/apple/apple_stringio.cpp index 81b9d8e0c..9554b2cd2 100644 --- a/renderdoc/os/posix/apple/apple_stringio.cpp +++ b/renderdoc/os/posix/apple/apple_stringio.cpp @@ -159,6 +159,12 @@ rdcstr GetAppFolderFilename(const rdcstr &filename) return ret + filename; } +rdcstr DefaultFindFileInPath(const rdcstr &fileName); +rdcstr FindFileInPath(const rdcstr &fileName) +{ + return DefaultFindFileInPath(fileName); +} + void GetExecutableFilename(rdcstr &selfName) { char path[512] = {0}; diff --git a/renderdoc/os/posix/ggp/ggp_stringio.cpp b/renderdoc/os/posix/ggp/ggp_stringio.cpp index 0a6ec053e..b0c2a5ce5 100644 --- a/renderdoc/os/posix/ggp/ggp_stringio.cpp +++ b/renderdoc/os/posix/ggp/ggp_stringio.cpp @@ -92,6 +92,12 @@ rdcstr GetAppFolderFilename(const rdcstr &filename) return ret + filename; } +rdcstr DefaultFindFileInPath(const rdcstr &fileName); +rdcstr FindFileInPath(const rdcstr &fileName) +{ + return DefaultFindFileInPath(fileName); +} + void GetExecutableFilename(rdcstr &selfName) { char path[512] = {0}; diff --git a/renderdoc/os/posix/linux/linux_stringio.cpp b/renderdoc/os/posix/linux/linux_stringio.cpp index 2f37b4f23..0626b2fc1 100644 --- a/renderdoc/os/posix/linux/linux_stringio.cpp +++ b/renderdoc/os/posix/linux/linux_stringio.cpp @@ -614,6 +614,12 @@ rdcstr GetAppFolderFilename(const rdcstr &filename) return ret + filename; } +rdcstr DefaultFindFileInPath(const rdcstr &fileName); +rdcstr FindFileInPath(const rdcstr &fileName) +{ + return DefaultFindFileInPath(fileName); +} + void GetExecutableFilename(rdcstr &selfName) { char path[512] = {0}; diff --git a/renderdoc/os/posix/posix_stringio.cpp b/renderdoc/os/posix/posix_stringio.cpp index 64c7800fd..ae2fd60de 100644 --- a/renderdoc/os/posix/posix_stringio.cpp +++ b/renderdoc/os/posix/posix_stringio.cpp @@ -101,7 +101,7 @@ rdcstr GetFullPathname(const rdcstr &filename) return rdcstr(path); } -rdcstr FindFileInPath(const rdcstr &fileName) +rdcstr DefaultFindFileInPath(const rdcstr &fileName) { rdcstr filePath;