diff options
author | Jeffrey Walton <noloader@gmail.com> | 2019-06-04 09:29:01 -0400 |
---|---|---|
committer | Jeffrey Walton <noloader@gmail.com> | 2019-06-04 09:29:01 -0400 |
commit | 198b081df5154cb10b2afd05c4d2a496e7baf316 (patch) | |
tree | a4bf1e3c1386d417c30279b3ebfb09ac5325460d /asn.h | |
parent | 238578a8082a62c6b2daf8920765f88d47602ff2 (diff) | |
download | cryptopp-git-198b081df5154cb10b2afd05c4d2a496e7baf316.tar.gz |
Add assert to RemainingLength member function
Diffstat (limited to 'asn.h')
-rw-r--r-- | asn.h | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -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
|