{
char cmpBuf[LZ4_COMPRESSBOUND(BLOCK_BYTES)];
- const int cmpBytes = LZ4_compress_continue(
- lz4Stream, inpPtr, cmpBuf, inpBytes);
+ const int cmpBytes = LZ4_compress_safe_continue(
+ lz4Stream, inpPtr, cmpBuf, inpBytes, sizeof(cmpBuf));
if(cmpBytes <= 0) {
break;
}
size_t ringBufferBytes)
{
LZ4_stream_t* const lz4Stream = LZ4_createStream();
- char* const cmpBuf = malloc(LZ4_COMPRESSBOUND(messageMaxBytes));
+ const size_t cmpBufBytes = LZ4_COMPRESSBOUND(messageMaxBytes);
+ char* const cmpBuf = malloc(cmpBufBytes);
char* const inpBuf = malloc(ringBufferBytes);
int inpOffset = 0;
#endif
{
- const int cmpBytes = LZ4_compress_continue(
- lz4Stream, inpPtr, cmpBuf, inpBytes);
+ const int cmpBytes = LZ4_compress_safe_continue(
+ lz4Stream, inpPtr, cmpBuf, inpBytes, cmpBufBytes);
if (cmpBytes <= 0) break;
write_uint16(outFp, (uint16_t) cmpBytes);
write_bin(outFp, cmpBuf, cmpBytes);