luben / zstd-jni

JNI binding for Zstd
Other
809 stars 165 forks source link

srcSize is incorrect #223

Closed jeffreye closed 2 years ago

jeffreye commented 2 years ago

https://github.com/luben/zstd-jni/blob/1f04f24d02bd7c74c890b1325766b808fb353b4e/src/main/java/com/github/luben/zstd/ZstdDecompressCtx.java#L251

Expected:

The srcSize should be srcBuf.limit()-srcBuf.position()

e.g. https://github.com/luben/zstd-jni/blob/1f04f24d02bd7c74c890b1325766b808fb353b4e/src/main/java/com/github/luben/zstd/ZstdDecompressCtx.java#L238-L243

Actual:

This will throw srcSize is incorrect if srcBuf.position() isn't 0

luben commented 2 years ago

yes, you are right. Looks there was miss in testing as we used buffers with postition() == 0