diff options
author | Igor Pavlov <ipavlov@users.sourceforge.net> | 2016-05-10 03:00:00 +0300 |
---|---|---|
committer | Kornel LesiĆski <kornel@geekhood.net> | 2016-05-28 02:16:59 +0300 |
commit | 66ac98bb02ac0fadd2a0e3266ea39279984580a3 (patch) | |
tree | c14c790212474e8b51df443d686b202cfe6b2315 /CPP/7zip/Common/LimitedStreams.cpp | |
parent | c20d013055085bf49b4c93b2c617030b10c1fb4d (diff) |
16.0016.00
Diffstat (limited to 'CPP/7zip/Common/LimitedStreams.cpp')
-rw-r--r-- | CPP/7zip/Common/LimitedStreams.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/CPP/7zip/Common/LimitedStreams.cpp b/CPP/7zip/Common/LimitedStreams.cpp index c7962167..8e032561 100644 --- a/CPP/7zip/Common/LimitedStreams.cpp +++ b/CPP/7zip/Common/LimitedStreams.cpp @@ -5,16 +5,19 @@ #include <string.h> #include "LimitedStreams.h" -#include "../../Common/Defs.h" STDMETHODIMP CLimitedSequentialInStream::Read(void *data, UInt32 size, UInt32 *processedSize) { UInt32 realProcessedSize = 0; - UInt32 sizeToRead = (UInt32)MyMin((_size - _pos), (UInt64)size); + { + const UInt64 rem = _size - _pos; + if (size > rem) + size = (UInt32)rem; + } HRESULT result = S_OK; - if (sizeToRead > 0) + if (size != 0) { - result = _stream->Read(data, sizeToRead, &realProcessedSize); + result = _stream->Read(data, size, &realProcessedSize); _pos += realProcessedSize; if (realProcessedSize == 0) _wasFinished = true; @@ -34,9 +37,11 @@ STDMETHODIMP CLimitedInStream::Read(void *data, UInt32 size, UInt32 *processedSi return S_OK; // return (_virtPos == _size) ? S_OK: E_FAIL; // ERROR_HANDLE_EOF } - UInt64 rem = _size - _virtPos; - if (rem < size) - size = (UInt32)rem; + { + const UInt64 rem = _size - _virtPos; + if (size > rem) + size = (UInt32)rem; + } UInt64 newPos = _startOffset + _virtPos; if (newPos != _physPos) { |