Commit 7d130612 authored by Andrea Bulgarelli's avatar Andrea Bulgarelli
Browse files

added exception generation if LZ4 decompression has problems

parent ae3ba7a0
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -177,10 +177,14 @@ ByteStreamPtr PacketLib::ByteStream::decompress(enum CompressionAlgorithms algor
			int buffsize = LZ4_decompress_safe((const char*)stream, (char*)tmpbuff, size(), dmax);
			if(!buffsize)
			{
				cout << "LZ4 decompression error" << endl;
				delete tmpbuff;
				throw new PacketException("LZ4 decompression error");
				return 0;
			}
			if(buffsize < 0) {
				delete tmpbuff;
				throw new PacketException("LZ4 decompression error: the source stream is malformed");
			}
			byte* decompbuff = new byte[buffsize];
			memcpy(decompbuff, tmpbuff, buffsize);
			b = ByteStreamPtr(new ByteStream(decompbuff, buffsize, bigendian));