8000 Additional checks in Xpress Dictionary Fill and Add. Should fix #20. · coderforlife/ms-compress@73ce174 · GitHub
[go: up one dir, main page]

Skip to content

Commit 73ce174

Browse files
committed
Additional checks in Xpress Dictionary Fill and Add. Should fix #20.
1 parent 4fca365 commit 73ce174

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

include/mscomp/XpressDictionary.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ class XpressDictionary
9898
INLINE const_bytes Fill(const_bytes data)
9999
{
100100
// equivalent to Add(data, ChunkSize)
101+
if (UNLIKELY(data >= this->end2)) { return this->end2; }
101102
uint32_t pos = WindowPos(data); // either 0x00000 or ChunkSize
102103
const const_bytes end = ((data + ChunkSize) < this->end2) ? data + ChunkSize : this->end2;
103104
uint_fast16_t hash = HashUpdate(data[0], data[1]);
@@ -123,6 +124,7 @@ class XpressDictionary
123124

124125
INLINE void Add(const_bytes data, size_t len)
125126
{
127+
if (UNLIKELY(data >= this->end2)) { return; }
126128
uint32_t pos = WindowPos(data);
127129
const const_bytes end = ((data + len) < this->end2) ? data + len : this->end2;
128130
uint_fast16_t hash = HashUpdate(data[0], data[1]);

0 commit comments

Comments
 (0)
0