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:
Cody Henthorne
2023-09-22 12:55:49 -04:00
committed by Alex Hart
parent 091f7c49ab
commit a7d9fd19d9
59 changed files with 874 additions and 7 deletions

View File

@@ -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();