Skip to content

Commit

Permalink
Fix net_data_writer::ensure only checked size of current write operat…
Browse files Browse the repository at this point in the history
…ion, not preparing for multiple writes
  • Loading branch information
olevs committed Sep 30, 2024
1 parent 2856b17 commit 8114b30
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions include/lnl/net_data_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,15 @@ namespace lnl {

private:
void ensure(size_t size) {
if (m_data.size() > size) {
size_t neededSize = size + m_position;
if (m_data.size() > neededSize) {
return;
}

do {
auto newSize = m_data.empty() ? 1 : m_data.size();
m_data.resize(newSize * GROWTH_FACTOR, 0);
} while (m_data.size() <= size);
} while (m_data.size() <= neededSize);
}
};
}
}

0 comments on commit 8114b30

Please sign in to comment.