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_posix.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_posix.cpp')
-rw-r--r-- | base/SharedMemory_posix.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/base/SharedMemory_posix.cpp b/base/SharedMemory_posix.cpp index 5198a6df..7bb91c8e 100644 --- a/base/SharedMemory_posix.cpp +++ b/base/SharedMemory_posix.cpp @@ -91,6 +91,11 @@ int SharedMemory::openInternal(int oflag, int mode, bool doMapping) { mFd = shm_open(mName.c_str(), oflag, mode); } else { mFd = ::open(mName.c_str(), oflag, mode); + // Make sure the file can hold at least mSize bytes.. + struct stat stat; + if (!fstat(mFd, &stat) && stat.st_size < mSize) { + ftruncate(mFd, mSize); + } } if (mFd == -1) { err = -errno; |