mirror of
https://github.com/M66B/FairEmail.git
synced 2025-03-04 02:28:18 +00:00
Simplification
This commit is contained in:
parent
e277be5d63
commit
8097b268a3
2 changed files with 21 additions and 9 deletions
|
@ -3863,24 +3863,36 @@ public class Helper {
|
|||
@Override
|
||||
public int read() throws IOException {
|
||||
int b = super.read();
|
||||
if (b >= 0 && ++count > max)
|
||||
throw new IOException("Stream larger than " + max + " bytes");
|
||||
if (b >= 0) {
|
||||
count++;
|
||||
checkLength();
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read(byte[] b) throws IOException {
|
||||
for (int i = 0; i < b.length; i++) {
|
||||
b[i] = (byte) read();
|
||||
if (b[i] < 0)
|
||||
return i;
|
||||
int read = super.read(b);
|
||||
if (read > 0) {
|
||||
count += read;
|
||||
checkLength();
|
||||
}
|
||||
return b.length;
|
||||
return read;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read(byte[] b, int off, int len) throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
int read = super.read(b, off, len);
|
||||
if (read > 0) {
|
||||
count += read;
|
||||
checkLength();
|
||||
}
|
||||
return read;
|
||||
}
|
||||
|
||||
private void checkLength() throws IOException {
|
||||
if (count > max)
|
||||
throw new IOException("Stream larger than " + max + " bytes");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -311,7 +311,7 @@ class ImageHelper {
|
|||
svg.renderToCanvas(canvas);
|
||||
return bm;
|
||||
} catch (Throwable ex) {
|
||||
throw new IOException("SVG, ex");
|
||||
throw new IOException("SVG, ex", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue