mirror of
https://github.com/stenzek/duckstation.git
synced 2024-11-23 22:09:53 +00:00
BinarySpanReaderWriter: Fix off-by-one error (#3230)
fix off-by-one error
This commit is contained in:
parent
ccb76d1451
commit
4827e548be
@ -62,7 +62,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
ALWAYS_INLINE bool Read(void* buf, size_t size)
|
ALWAYS_INLINE bool Read(void* buf, size_t size)
|
||||||
{
|
{
|
||||||
if ((m_pos + size) < m_buf.size()) [[likely]]
|
if ((m_pos + size) <= m_buf.size()) [[likely]]
|
||||||
{
|
{
|
||||||
std::memcpy(buf, &m_buf[m_pos], size);
|
std::memcpy(buf, &m_buf[m_pos], size);
|
||||||
m_pos += size;
|
m_pos += size;
|
||||||
@ -74,7 +74,7 @@ private:
|
|||||||
|
|
||||||
ALWAYS_INLINE bool Peek(void* buf, size_t size)
|
ALWAYS_INLINE bool Peek(void* buf, size_t size)
|
||||||
{
|
{
|
||||||
if ((m_pos + size) < m_buf.size()) [[likely]]
|
if ((m_pos + size) <= m_buf.size()) [[likely]]
|
||||||
{
|
{
|
||||||
std::memcpy(buf, &m_buf[m_pos], size);
|
std::memcpy(buf, &m_buf[m_pos], size);
|
||||||
return true;
|
return true;
|
||||||
@ -119,7 +119,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
ALWAYS_INLINE bool Write(void* buf, size_t size)
|
ALWAYS_INLINE bool Write(void* buf, size_t size)
|
||||||
{
|
{
|
||||||
if ((m_pos + size) < m_buf.size()) [[likely]]
|
if ((m_pos + size) <= m_buf.size()) [[likely]]
|
||||||
{
|
{
|
||||||
std::memcpy(&m_buf[m_pos], buf, size);
|
std::memcpy(&m_buf[m_pos], buf, size);
|
||||||
m_pos += size;
|
m_pos += size;
|
||||||
|
Loading…
Reference in New Issue
Block a user