We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 7e89fdc commit ad7b8efCopy full SHA for ad7b8ef
src/OrcLib/PEInfo.cpp
@@ -1,4 +1,3 @@
1
-//
2
// SPDX-License-Identifier: LGPL-2.1-or-later
3
//
4
// Copyright © 2011-2021 ANSSI. All Rights Reserved.
@@ -159,12 +158,15 @@ HRESULT PEInfo::OpenPEInformation()
159
158
return hr;
160
buf.SetCount(static_cast<size_t>(ullBytesRead));
161
162
- if (buf.GetCount() >= BYTES_IN_FIRSTBYTES)
+ if (!buf.empty())
163
{
164
CBinaryBuffer fb;
165
- if (!fb.SetCount(BYTES_IN_FIRSTBYTES))
+ if (!fb.SetCount(std::min(static_cast<size_t>(BYTES_IN_FIRSTBYTES), buf.GetCount())))
+ {
166
return E_OUTOFMEMORY;
167
- CopyMemory(fb.GetData(), buf.GetData(), BYTES_IN_FIRSTBYTES);
+ }
168
+
169
+ CopyMemory(fb.GetData(), buf.GetData(), fb.GetCount());
170
m_FileInfo.GetDetails()->SetFirstBytes(std::move(fb));
171
}
172
0 commit comments