VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Platform/Buffer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Platform/Buffer.cpp')
-rw-r--r--src/Platform/Buffer.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/Platform/Buffer.cpp b/src/Platform/Buffer.cpp
index 6fd8a01a..f0b7b693 100644
--- a/src/Platform/Buffer.cpp
+++ b/src/Platform/Buffer.cpp
@@ -58,11 +58,15 @@ namespace VeraCrypt
void Buffer::CopyFrom (const ConstBufferPtr &bufferPtr)
{
if (!IsAllocated ())
- Allocate (bufferPtr.Size());
+ {
+ if (bufferPtr.Size())
+ Allocate (bufferPtr.Size());
+ }
else if (bufferPtr.Size() > DataSize)
throw ParameterTooLarge (SRC_POS);
- Memory::Copy (DataPtr, bufferPtr.Get(), bufferPtr.Size());
+ if (bufferPtr.Size())
+ Memory::Copy (DataPtr, bufferPtr.Get(), bufferPtr.Size());
}
void Buffer::Erase ()