diff options
| author | Stefan Boberg <[email protected]> | 2023-05-25 14:18:27 +0200 |
|---|---|---|
| committer | Stefan Boberg <[email protected]> | 2023-05-25 14:18:27 +0200 |
| commit | 4c99d556c8b065d62f1fc8f5c974e1a9fa9276ee (patch) | |
| tree | 7aa0f57bb024e778a47641d7c498731a7016e48b /src/zenutil/basicfile.cpp | |
| parent | added defaults to remote project store option definitions (diff) | |
| download | zen-4c99d556c8b065d62f1fc8f5c974e1a9fa9276ee.tar.xz zen-4c99d556c8b065d62f1fc8f5c974e1a9fa9276ee.zip | |
BasicFile::ReadAll should handle zero-sized files gracefully
Diffstat (limited to 'src/zenutil/basicfile.cpp')
| -rw-r--r-- | src/zenutil/basicfile.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/zenutil/basicfile.cpp b/src/zenutil/basicfile.cpp index 1e6043d7e..22acc346f 100644 --- a/src/zenutil/basicfile.cpp +++ b/src/zenutil/basicfile.cpp @@ -179,9 +179,16 @@ BasicFile::Read(void* Data, uint64_t BytesToRead, uint64_t FileOffset) IoBuffer BasicFile::ReadAll() { - IoBuffer Buffer(FileSize()); - Read(Buffer.MutableData(), Buffer.Size(), 0); - return Buffer; + if (const uint64_t Size = FileSize()) + { + IoBuffer Buffer(Size); + Read(Buffer.MutableData(), Size, 0); + return Buffer; + } + else + { + return {}; + } } void |