diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2020-04-08 16:49:28 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2020-04-08 19:17:19 +0200 |
commit | cbf8f54cb062a92aa9b3928a7b2158de5175a895 (patch) | |
tree | be6f2ff214cfe3dff8ce20a2718750ba022e8823 /openpgp/src/packet_pile.rs | |
parent | 759074ef27a8e5c7832c22cc6d110d2862d39a44 (diff) |
openpgp: Fix error handling.
Diffstat (limited to 'openpgp/src/packet_pile.rs')
-rw-r--r-- | openpgp/src/packet_pile.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/openpgp/src/packet_pile.rs b/openpgp/src/packet_pile.rs index bd640aa5..57a0fa16 100644 --- a/openpgp/src/packet_pile.rs +++ b/openpgp/src/packet_pile.rs @@ -350,7 +350,12 @@ impl<'a> TryFrom<PacketParserResult<'a>> for PacketPile { // it is hard to imagine that that is what the caller wants. // Instead of hiding that error, fail fast. if let PacketParserResult::Some(ref pp) = ppr { - assert_eq!(pp.recursion_depth(), 0); + if pp.recursion_depth() != 0 { + return Err(Error::InvalidOperation( + format!("Expected top-level packet, \ + but the parser is at level {}", + pp.recursion_depth())).into()); + } } // Create a top-level container. |