summaryrefslogtreecommitdiff
path: root/asn.h
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2019-06-04 09:29:01 -0400
committerJeffrey Walton <noloader@gmail.com>2019-06-04 09:29:01 -0400
commit198b081df5154cb10b2afd05c4d2a496e7baf316 (patch)
treea4bf1e3c1386d417c30279b3ebfb09ac5325460d /asn.h
parent238578a8082a62c6b2daf8920765f88d47602ff2 (diff)
downloadcryptopp-git-198b081df5154cb10b2afd05c4d2a496e7baf316.tar.gz
Add assert to RemainingLength member function
Diffstat (limited to 'asn.h')
-rw-r--r--asn.h11
1 files changed, 9 insertions, 2 deletions
diff --git a/asn.h b/asn.h
index 4ce1fa35..c1f262a7 100644
--- a/asn.h
+++ b/asn.h
@@ -285,11 +285,18 @@ public:
/// \brief Determine length encoding
/// \returns true if the ASN.1 object is definite length encoded, false otherwise
- bool IsDefiniteLength() const {return m_definiteLength;}
+ bool IsDefiniteLength() const {
+ return m_definiteLength;
+ }
/// \brief Determine remaining length
/// \returns number of octets that remain to be consumed
- lword RemainingLength() const {return m_length;}
+ /// \details RemainingLength() is only valid if IsDefiniteLength()
+ /// returns true.
+ lword RemainingLength() const {
+ CRYPTOPP_ASSERT(m_definiteLength);
+ return IsDefiniteLength() ? m_length : 0;
+ }
/// \brief Determine end of stream
/// \returns true if all octets have been consumed, false otherwise