Stop reusing winstd::eap_attr after moved from

MSVC C26800 warned us an object is not guaranteed to be cleared after
being moved from. At least in std C++ implementations.

Thou winstd does clear all objects after being moved from, we could just
silence C26800 warning. But what if some day winstd behavior changes and
with us having this warning silenced?

std::eap_attr has no clear() method, therefore revert to using scope and
temporary object. It achieves the same effect as clear after moved from
does.

Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
Simon Rozman 2022-10-28 14:00:45 +02:00
parent 887129ccc0
commit 0f3070033f

View File

@ -530,8 +530,6 @@ void eap::method_tls::get_result(
method::get_result(reason, pResult);
if (reason == EapPeerMethodResultSuccess) {
eap_attr a;
// Prepare EAP result attributes.
if (pResult->pAttribArray) {
m_eap_attr.reserve((size_t)pResult->pAttribArray->dwNumberOfAttributes + 3);
@ -551,12 +549,18 @@ void eap::method_tls::get_result(
get_keying_material(recv, send);
// MSK: MPPE-Recv-Key
a.create_ms_mppe_key(16, recv.data, sizeof(recv.data));
m_eap_attr.push_back(std::move(a));
{
eap_attr a;
a.create_ms_mppe_key(16, recv.data, sizeof(recv.data));
m_eap_attr.push_back(std::move(a));
}
// MSK: MPPE-Send-Key
a.create_ms_mppe_key(17, send.data, sizeof(send.data));
m_eap_attr.push_back(std::move(a));
{
eap_attr a;
a.create_ms_mppe_key(17, send.data, sizeof(send.data));
m_eap_attr.push_back(std::move(a));
}
// Append blank EAP attribute.
m_eap_attr.push_back(blank_eap_attr);