diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2021-11-04 09:34:57 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2021-11-04 10:06:25 +0100 |
commit | cab8eb207d24c3c3050801fee02deffa959d9c0f (patch) | |
tree | 7d48a86220aa1078f0536bfce21ad092ca50c3ce /openpgp | |
parent | 626652afde60a4d064c912ed2a75034059ae7d02 (diff) |
openpgp: Don't try to fill the buffer if we reached the end.
- Previously, when the read exceeded the buffered data, we tried to
fill the buffer even if we reached the last chunk. Then, we would
allocate a new buffer and copy the data over, only to later
realize that we reached the last chunk and the current chunk is
exhausted.
Diffstat (limited to 'openpgp')
-rw-r--r-- | openpgp/src/parse/partial_body.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/openpgp/src/parse/partial_body.rs b/openpgp/src/parse/partial_body.rs index 1bd4e863..4f72c5d2 100644 --- a/openpgp/src/parse/partial_body.rs +++ b/openpgp/src/parse/partial_body.rs @@ -95,6 +95,12 @@ impl<T: BufferedReader<Cookie>> BufferedReaderPartialBodyFilter<T> { amount, self.partial_body_length, self.last); } + if self.last && self.partial_body_length == 0 { + // We reached the end. Avoid fruitlessly copying data + // over and over again trying to buffer more data. + return Ok(()); + } + // We want to avoid double buffering as much as possible. // Thus, we only buffer as much as needed. let mut buffer = self.unused_buffers.pop() |