forked from organicmaps/organicmaps
Fix invalid memory usage in MemWriter
Case 1: `m_Data.size() == 0 && m_Pos == 0` => `resize` is not called. Case 2: `size == 0` => access to `m_Data[m_Data.size()]` Signed-off-by: Osyotr <Osyotr@users.noreply.github.com>
This commit is contained in:
parent
863c755894
commit
ae7027a36f
1 changed files with 4 additions and 1 deletions
|
@ -61,8 +61,11 @@ public:
|
|||
|
||||
void Write(void const * p, size_t size) override
|
||||
{
|
||||
if (size == 0)
|
||||
return;
|
||||
|
||||
auto freeSize = static_cast<intptr_t>(m_Data.size() - m_Pos);
|
||||
if (freeSize < 0)
|
||||
if (freeSize <= 0)
|
||||
{
|
||||
m_Data.resize(static_cast<size_t>(m_Pos + size));
|
||||
freeSize = size;
|
||||
|
|
Loading…
Add table
Reference in a new issue