From f5e3165cc3e1b129f4c81f7441126c127b2d8ddc Mon Sep 17 00:00:00 2001 From: Dmitri Smirnov Date: Tue, 18 Oct 2022 13:07:40 -0700 Subject: [PATCH] Fix move Base::operator= (#13355) ### Description Base::operator= move is broken, loses a valid ptr. ### Motivation and Context Address https://github.com/microsoft/onnxruntime/pull/13215#discussion_r997814275 --- include/onnxruntime/core/session/onnxruntime_cxx_api.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/onnxruntime/core/session/onnxruntime_cxx_api.h b/include/onnxruntime/core/session/onnxruntime_cxx_api.h index 7c344f57db..dc102b8904 100644 --- a/include/onnxruntime/core/session/onnxruntime_cxx_api.h +++ b/include/onnxruntime/core/session/onnxruntime_cxx_api.h @@ -292,8 +292,8 @@ struct Base> { Base(Base&& v) noexcept : p_{v.p_} { v.p_ = nullptr; } Base& operator=(Base&& v) noexcept { - auto t = nullptr; - std::swap(t, v.p_); + p_ = nullptr; + std::swap(p_, v.p_); return *this; }