diff options
author | Bartosz Taudul <wolf.pld@gmail.com> | 2020-03-01 16:04:10 +0300 |
---|---|---|
committer | Bartosz Taudul <wolf.pld@gmail.com> | 2020-03-01 16:04:10 +0300 |
commit | abd44069ae28520367401bc896be10457a801a29 (patch) | |
tree | b5958383015a994b716b65c0129f50d9ae137d24 /server/TracyFileRead.hpp | |
parent | 0b3431289f2184c201a20a194b22623f30f2331b (diff) |
Fix off-by-one.
Diffstat (limited to 'server/TracyFileRead.hpp')
-rw-r--r-- | server/TracyFileRead.hpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/server/TracyFileRead.hpp b/server/TracyFileRead.hpp index bf4fcada..dfd99b69 100644 --- a/server/TracyFileRead.hpp +++ b/server/TracyFileRead.hpp @@ -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 ) ); |