mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +00:00
Fix off-by-one.
This commit is contained in:
parent
0b3431289f
commit
abd44069ae
@ -79,7 +79,7 @@ public:
|
||||
template<class T>
|
||||
tracy_force_inline void Read( T& v )
|
||||
{
|
||||
if( sizeof( T ) < BufSize - m_offset )
|
||||
if( sizeof( T ) <= BufSize - m_offset )
|
||||
{
|
||||
memcpy( &v, m_buf + m_offset, sizeof( T ) );
|
||||
m_offset += sizeof( T );
|
||||
@ -96,7 +96,7 @@ public:
|
||||
template<class T, class U>
|
||||
tracy_force_inline void Read2( T& v0, U& v1 )
|
||||
{
|
||||
if( sizeof( T ) + sizeof( U ) < BufSize - m_offset )
|
||||
if( sizeof( T ) + sizeof( U ) <= BufSize - m_offset )
|
||||
{
|
||||
memcpy( &v0, m_buf + m_offset, sizeof( T ) );
|
||||
memcpy( &v1, m_buf + m_offset + sizeof( T ), sizeof( U ) );
|
||||
@ -114,7 +114,7 @@ public:
|
||||
template<class T, class U, class V>
|
||||
tracy_force_inline void Read3( T& v0, U& v1, V& v2 )
|
||||
{
|
||||
if( sizeof( T ) + sizeof( U ) + sizeof( V ) < BufSize - m_offset )
|
||||
if( sizeof( T ) + sizeof( U ) + sizeof( V ) <= BufSize - m_offset )
|
||||
{
|
||||
memcpy( &v0, m_buf + m_offset, sizeof( T ) );
|
||||
memcpy( &v1, m_buf + m_offset + sizeof( T ), sizeof( U ) );
|
||||
@ -134,7 +134,7 @@ public:
|
||||
template<class T, class U, class V, class W>
|
||||
tracy_force_inline void Read4( T& v0, U& v1, V& v2, W& v3 )
|
||||
{
|
||||
if( sizeof( T ) + sizeof( U ) + sizeof( V ) + sizeof( W ) < BufSize - m_offset )
|
||||
if( sizeof( T ) + sizeof( U ) + sizeof( V ) + sizeof( W ) <= BufSize - m_offset )
|
||||
{
|
||||
memcpy( &v0, m_buf + m_offset, sizeof( T ) );
|
||||
memcpy( &v1, m_buf + m_offset + sizeof( T ), sizeof( U ) );
|
||||
@ -156,7 +156,7 @@ public:
|
||||
template<class T, class U, class V, class W, class X>
|
||||
tracy_force_inline void Read5( T& v0, U& v1, V& v2, W& v3, X& v4 )
|
||||
{
|
||||
if( sizeof( T ) + sizeof( U ) + sizeof( V ) + sizeof( W ) + sizeof( X ) < BufSize - m_offset )
|
||||
if( sizeof( T ) + sizeof( U ) + sizeof( V ) + sizeof( W ) + sizeof( X ) <= BufSize - m_offset )
|
||||
{
|
||||
memcpy( &v0, m_buf + m_offset, sizeof( T ) );
|
||||
memcpy( &v1, m_buf + m_offset + sizeof( T ), sizeof( U ) );
|
||||
@ -180,7 +180,7 @@ public:
|
||||
template<class T, class U, class V, class W, class X, class Y>
|
||||
tracy_force_inline void Read6( T& v0, U& v1, V& v2, W& v3, X& v4, Y& v5 )
|
||||
{
|
||||
if( sizeof( T ) + sizeof( U ) + sizeof( V ) + sizeof( W ) + sizeof( X ) + sizeof( Y ) < BufSize - m_offset )
|
||||
if( sizeof( T ) + sizeof( U ) + sizeof( V ) + sizeof( W ) + sizeof( X ) + sizeof( Y ) <= BufSize - m_offset )
|
||||
{
|
||||
memcpy( &v0, m_buf + m_offset, sizeof( T ) );
|
||||
memcpy( &v1, m_buf + m_offset + sizeof( T ), sizeof( U ) );
|
||||
@ -206,7 +206,7 @@ public:
|
||||
template<class T, class U, class V, class W, class X, class Y, class Z>
|
||||
tracy_force_inline void Read7( T& v0, U& v1, V& v2, W& v3, X& v4, Y& v5, Z& v6 )
|
||||
{
|
||||
if( sizeof( T ) + sizeof( U ) + sizeof( V ) + sizeof( W ) + sizeof( X ) + sizeof( Y ) + sizeof( Z ) < BufSize - m_offset )
|
||||
if( sizeof( T ) + sizeof( U ) + sizeof( V ) + sizeof( W ) + sizeof( X ) + sizeof( Y ) + sizeof( Z ) <= BufSize - m_offset )
|
||||
{
|
||||
memcpy( &v0, m_buf + m_offset, sizeof( T ) );
|
||||
memcpy( &v1, m_buf + m_offset + sizeof( T ), sizeof( U ) );
|
||||
@ -234,7 +234,7 @@ public:
|
||||
template<class T, class U, class V, class W, class X, class Y, class Z, class A>
|
||||
tracy_force_inline void Read8( T& v0, U& v1, V& v2, W& v3, X& v4, Y& v5, Z& v6, A& v7 )
|
||||
{
|
||||
if( sizeof( T ) + sizeof( U ) + sizeof( V ) + sizeof( W ) + sizeof( X ) + sizeof( Y ) + sizeof( Z ) + sizeof( A ) < BufSize - m_offset )
|
||||
if( sizeof( T ) + sizeof( U ) + sizeof( V ) + sizeof( W ) + sizeof( X ) + sizeof( Y ) + sizeof( Z ) + sizeof( A ) <= BufSize - m_offset )
|
||||
{
|
||||
memcpy( &v0, m_buf + m_offset, sizeof( T ) );
|
||||
memcpy( &v1, m_buf + m_offset + sizeof( T ), sizeof( U ) );
|
||||
|
Loading…
Reference in New Issue
Block a user