Skip to content

Commit

Permalink
Encoder wrong length during push op (#127)
Browse files Browse the repository at this point in the history
Motivation:

Currently, the Java wrapper Encoder passes byte array length for finishing data encoding. This is ideal when the encoder is used with offset 0 and full length is passed but for cases where offset is passed and length is also specified, it leads to encoded data corruption.

Modification:
Instead of passing byte array length to the `push` method, we will now pass `length` directly.

Result:
Error-free encoding
  • Loading branch information
hyperxpro authored Dec 28, 2023
1 parent 0907a38 commit 8f178b8
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static byte[] compress(byte[] data, int offset, int length, Parameters pa
int totalOutputSize = 0;
try {
encoder.getInputBuffer().put(data, offset, length);
encoder.push(EncoderJNI.Operation.FINISH, data.length);
encoder.push(EncoderJNI.Operation.FINISH, length);
while (true) {
if (!encoder.isSuccess()) {
throw new IOException("encoding failed");
Expand Down

0 comments on commit 8f178b8

Please sign in to comment.