Skip to content

Commit 0e8f777

Browse files
committed
minor changes
1 parent 7fcc441 commit 0e8f777

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/test/java/org/xerial/snappy/fuzz/SnappyCombinedFuzzer.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,16 +311,19 @@ private static void testByteBuffer(FuzzedDataProvider data) {
311311
byte[] input = data.consumeRemainingAsBytes();
312312

313313
try {
314-
ByteBuffer src = ByteBuffer.wrap(input);
315-
ByteBuffer dst = ByteBuffer.allocate(Snappy.maxCompressedLength(input.length));
314+
ByteBuffer src = ByteBuffer.allocateDirect(input.length);
315+
src.put(input);
316+
src.flip();
317+
ByteBuffer dst = ByteBuffer.allocateDirect(Snappy.maxCompressedLength(input.length));
316318
int compressed = Snappy.compress(src, dst);
317319

318320
dst.limit(compressed);
319321
dst.position(0);
320-
ByteBuffer uncompressedBuf = ByteBuffer.allocate(input.length);
322+
ByteBuffer uncompressedBuf = ByteBuffer.allocateDirect(input.length);
321323
int uncompressed = Snappy.uncompress(dst, uncompressedBuf);
322324

323325
uncompressedBuf.limit(uncompressed);
326+
uncompressedBuf.position(0);
324327
byte[] result = new byte[uncompressed];
325328
uncompressedBuf.get(result);
326329

0 commit comments

Comments
 (0)