Skip to content

Commit

Permalink
Rewind ByteBuffers in ByteBufferUtil.toFile.
Browse files Browse the repository at this point in the history
This avoids writing partial data if the buffer is not at position 0 when the method is called. This fixes a bug where using DiskCacheStrategy.ALL
or DiskCacheStrategy.RESOURCE with GifDrawables would result in partial
and invalid gif files being written to Glide’s disk cache.
  • Loading branch information
sjudd committed Aug 15, 2017
1 parent cac7192 commit 1594655
Showing 1 changed file with 1 addition and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public static ByteBuffer fromFile(File file) throws IOException {
}

public static void toFile(ByteBuffer buffer, File file) throws IOException {
buffer.position(0);
RandomAccessFile raf = null;
FileChannel channel = null;
try {
Expand Down

0 comments on commit 1594655

Please sign in to comment.