mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-27 14:40:22 +00:00
Enable WebP decoding in Signal using libwebp v1.3.2
Co-authored-by: Greyson Parrelli <greyson@signal.org> Co-authored-by: Greyson Parrelli <greyson@pop-os.localdomain>
This commit is contained in:
committed by
Alex Hart
parent
091f7c49ab
commit
a7d9fd19d9
@@ -60,12 +60,21 @@ public final class StreamUtil {
|
||||
}
|
||||
|
||||
public static byte[] readFully(InputStream in) throws IOException {
|
||||
ByteArrayOutputStream bout = new ByteArrayOutputStream();
|
||||
byte[] buffer = new byte[4096];
|
||||
int read;
|
||||
return readFully(in, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
public static byte[] readFully(InputStream in, int maxBytes) throws IOException {
|
||||
ByteArrayOutputStream bout = new ByteArrayOutputStream();
|
||||
byte[] buffer = new byte[4096];
|
||||
int totalRead = 0;
|
||||
int read;
|
||||
|
||||
while ((read = in.read(buffer)) != -1) {
|
||||
bout.write(buffer, 0, read);
|
||||
totalRead += read;
|
||||
if (totalRead > maxBytes) {
|
||||
throw new IOException("Stream size limit exceeded");
|
||||
}
|
||||
}
|
||||
|
||||
in.close();
|
||||
|
||||
Reference in New Issue
Block a user