Skip to content
Snippets Groups Projects
Commit 7d130612 authored by Andrea Bulgarelli's avatar Andrea Bulgarelli
Browse files

added exception generation if LZ4 decompression has problems

parent ae3ba7a0
No related branches found
No related tags found
No related merge requests found
...@@ -177,10 +177,14 @@ ByteStreamPtr PacketLib::ByteStream::decompress(enum CompressionAlgorithms algor ...@@ -177,10 +177,14 @@ ByteStreamPtr PacketLib::ByteStream::decompress(enum CompressionAlgorithms algor
int buffsize = LZ4_decompress_safe((const char*)stream, (char*)tmpbuff, size(), dmax); int buffsize = LZ4_decompress_safe((const char*)stream, (char*)tmpbuff, size(), dmax);
if(!buffsize) if(!buffsize)
{ {
cout << "LZ4 decompression error" << endl;
delete tmpbuff; delete tmpbuff;
throw new PacketException("LZ4 decompression error");
return 0; return 0;
} }
if(buffsize < 0) {
delete tmpbuff;
throw new PacketException("LZ4 decompression error: the source stream is malformed");
}
byte* decompbuff = new byte[buffsize]; byte* decompbuff = new byte[buffsize];
memcpy(decompbuff, tmpbuff, buffsize); memcpy(decompbuff, tmpbuff, buffsize);
b = ByteStreamPtr(new ByteStream(decompbuff, buffsize, bigendian)); b = ByteStreamPtr(new ByteStream(decompbuff, buffsize, bigendian));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment