mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-24 13:08:46 +00:00
Close stream after calculating length.
This commit is contained in:
committed by
Cody Henthorne
parent
8070f26207
commit
6c09b59d1b
@@ -185,8 +185,12 @@ public final class PartProvider extends BaseContentProvider {
|
||||
}
|
||||
|
||||
private ParcelFileDescriptor getParcelStreamForAttachment(AttachmentId attachmentId) throws IOException {
|
||||
long plaintextLength = StreamUtil.getStreamLength(SignalDatabase.attachments().getAttachmentStream(attachmentId, 0));
|
||||
MemoryFile memoryFile = new MemoryFile(attachmentId.toString(), Util.toIntExact(plaintextLength));
|
||||
long plaintextLength;
|
||||
try (InputStream in = SignalDatabase.attachments().getAttachmentStream(attachmentId, 0)) {
|
||||
plaintextLength = StreamUtil.getStreamLength(in);
|
||||
}
|
||||
|
||||
MemoryFile memoryFile = new MemoryFile(attachmentId.toString(), Util.toIntExact(plaintextLength));
|
||||
|
||||
InputStream in = SignalDatabase.attachments().getAttachmentStream(attachmentId, 0);
|
||||
OutputStream out = memoryFile.getOutputStream();
|
||||
|
||||
Reference in New Issue
Block a user