diff options
author | Doug Horn <doughorn@google.com> | 2021-01-07 12:36:04 -0800 |
---|---|---|
committer | Doug Horn <doughorn@google.com> | 2021-01-07 12:36:07 -0800 |
commit | d7b578731645aa338970c24110337561a1ca58ce (patch) | |
tree | 193f50d94db61f7d7db2f7cd1f8bb29c6e5161cb /base/SharedMemory_win32.cpp | |
parent | 36fa8a7f89f6e89bf00313f18f1290059284fc54 (diff) | |
download | vulkan-cereal-d7b578731645aa338970c24110337561a1ca58ce.tar.gz |
[Win] Properly parse all valid Win32 file urls.
We now make sure we properly parse all file:// urls properly for the
windows platform.
Includes a unit test to validate parsing.
This is a manual cherry-pick of aosp/1483306.
Change-Id: I80d16ee1ed77db3c6024635f16ddc6ae12106020
Diffstat (limited to 'base/SharedMemory_win32.cpp')
-rw-r--r-- | base/SharedMemory_win32.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/base/SharedMemory_win32.cpp b/base/SharedMemory_win32.cpp index 6b253f10..b6214ddd 100644 --- a/base/SharedMemory_win32.cpp +++ b/base/SharedMemory_win32.cpp @@ -13,6 +13,7 @@ // limitations under the License. #include "base/SharedMemory.h" +#include <shlwapi.h> #include <cassert> #include <string> @@ -25,9 +26,15 @@ namespace base { SharedMemory::SharedMemory(const std::string& name, size_t size) : mSize(size) { const std::string kFileUri = "file://"; if (name.find(kFileUri, 0) == 0) { + // Convert URI to path using win32 api. + const Win32UnicodeString srcUri(name); + WCHAR path[MAX_PATH]; + DWORD cPath = MAX_PATH; + auto HR = PathCreateFromUrlW(srcUri.c_str(), path, &cPath, NULL); + assert(HR == S_OK); + const Win32UnicodeString destPath(path); + mName = PathUtils::recompose(PathUtils::decompose(destPath.toString())); mShareType = ShareType::FILE_BACKED; - auto path = name.substr(kFileUri.size()); - mName = PathUtils::recompose(PathUtils::decompose(path)); } else { mShareType = ShareType::SHARED_MEMORY; mName = "SHM_" + name; |