From 0f3070033fd4cde3795ec13a745d945632e84f84 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Fri, 28 Oct 2022 14:00:45 +0200 Subject: [PATCH] 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 --- lib/TLS/src/Method.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/TLS/src/Method.cpp b/lib/TLS/src/Method.cpp index 9db99d8..4121c4d 100644 --- a/lib/TLS/src/Method.cpp +++ b/lib/TLS/src/Method.cpp @@ -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);