diff --git a/src/fe_utils/astreamer_lz4.c b/src/fe_utils/astreamer_lz4.c index a5865c93598..03e306c317b 100644 --- a/src/fe_utils/astreamer_lz4.c +++ b/src/fe_utils/astreamer_lz4.c @@ -331,10 +331,15 @@ astreamer_lz4_decompressor_content(astreamer *streamer, size_t ret, read_size, out_size; + size_t hack_out_size; read_size = avail_in; out_size = avail_out; + if (out_size > 5) + hack_out_size = out_size - 5; + else + hack_out_size = out_size; /* * This call decompresses the data starting at next_in and generates * the output data starting at next_out. It expects the caller to @@ -349,13 +354,15 @@ astreamer_lz4_decompressor_content(astreamer *streamer, * to out_size respectively. */ ret = LZ4F_decompress(mystreamer->dctx, - next_out, &out_size, + next_out, &hack_out_size, next_in, &read_size, NULL); if (LZ4F_isError(ret)) pg_log_error("could not decompress data: %s", LZ4F_getErrorName(ret)); + out_size = hack_out_size; + /* Update input buffer based on number of bytes consumed */ avail_in -= read_size; next_in += read_size;