weidai11 / cryptopp

free C++ class library of cryptographic schemes
https://cryptopp.com
Other
4.87k stars 1.51k forks source link

Debug asserts in TestDataNameValuePairs #827

Closed noloader closed 5 years ago

noloader commented 5 years ago

We cut-over to inline functions that retrieve a BytePtr or ConstBytePtr from a std::string. The function handles the casts and asserts so we don't have to use the pattern throughout the code.

We are catching some asserts in Debug builds that we could sidestep. The current code in datatest.cpp uses a BytePtr, but it could use a ConstBytePtr like shown below (from around line 285):

else if (valueType == typeid(ConstByteArrayParameter))
{
    m_temp.clear();
    PutDecodedDatumInto(m_data, name, StringSink(m_temp).Ref());
    reinterpret_cast<ConstByteArrayParameter *>(pValue)->Assign(ConstBytePtr(m_temp), BytePtrSize(m_temp), false);
}

This will track the change.

noloader commented 5 years ago

Cleared at Commit a11ac1e87973.