File tree Expand file tree Collapse file tree
src/test/java/org/xerial/snappy/fuzz Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments