diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2020-04-20 11:53:11 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2020-04-20 18:43:42 +0200 |
commit | 869258d34ffb83ef8790d94a6325ffef8037f419 (patch) | |
tree | 694d7f72a5123dd5a280aa35d3d55c2e5515ba94 /openpgp/src/serialize/stream.rs | |
parent | c66712681b1367eea110edf8dc25dcf5c937828b (diff) |
openpgp: Don't finalize the Encryptor in Drop.
- Previously, Encryptor::drop made an effort to finalize the filter.
This, however, is only a best-effort mechanism: It cannot report
errors.
- Because of this, we now believe that it actually exacerbates the
problem of downstream users not finalizing the filter: It will
work most of the time, but sometimes fail.
Diffstat (limited to 'openpgp/src/serialize/stream.rs')
-rw-r--r-- | openpgp/src/serialize/stream.rs | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/openpgp/src/serialize/stream.rs b/openpgp/src/serialize/stream.rs index 0a6c0851..a913684a 100644 --- a/openpgp/src/serialize/stream.rs +++ b/openpgp/src/serialize/stream.rs @@ -1770,6 +1770,11 @@ impl<'a> Recipient<'a> { /// will be encrypted using the given passwords, and for all given /// recipients. pub struct Encryptor<'a> { + // XXX: Opportunity for optimization. Previously, this writer + // implemented `Drop`, so we could not move the inner writer out + // of this writer. We therefore wrapped it with `Option` so that + // we can `take()` it. This writer no longer implements Drop, so + // we could avoid the Option here. inner: Option<writer::BoxStack<'a, Cookie>>, recipients: Vec<Recipient<'a>>, passwords: Vec<Password>, @@ -2314,12 +2319,6 @@ impl<'a> Encryptor<'a> { } } -impl<'a> Drop for Encryptor<'a> { - fn drop(&mut self) { - let _ = self.emit_mdc(); - } -} - impl<'a> fmt::Debug for Encryptor<'a> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("Encryptor") |