mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
plugin/lz4: Fixed corner case issues
git-svn-id: svn://ultimatepp.org/upp/trunk@10014 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
be3f64361b
commit
34fba411d7
1 changed files with 9 additions and 8 deletions
|
|
@ -189,10 +189,11 @@ void Lz4::Put(const void *ptr_, int size)
|
|||
else {
|
||||
int count = Peek32le(~buffer);
|
||||
int len = count & 0x7fffffff;
|
||||
if(len > maxblock)
|
||||
if(len > maxblock) {
|
||||
error = true;
|
||||
else
|
||||
if(count == 0) {
|
||||
break;
|
||||
}
|
||||
if(count == 0) { // reached the end
|
||||
int need = 4 - pos + 4;
|
||||
if(size >= need) { // we have enough data for final checksum
|
||||
memcpy(~buffer + pos, ptr, need);
|
||||
|
|
@ -203,6 +204,7 @@ void Lz4::Put(const void *ptr_, int size)
|
|||
size -= need;
|
||||
ptr += need;
|
||||
pos = 0;
|
||||
return; // decompression completed
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
@ -230,13 +232,12 @@ void Lz4::Put(const void *ptr_, int size)
|
|||
ptr += need;
|
||||
size -= need;
|
||||
pos = 0;
|
||||
}
|
||||
else {
|
||||
memcpy(~buffer + pos, ptr, size);
|
||||
pos += size;
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
memcpy(~buffer + pos, ptr, size);
|
||||
pos += size;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue