From d16cf31c61d4206026aaae77fcde44abc1cb6351 Mon Sep 17 00:00:00 2001 From: Shahzad Malik Muzaffar Date: Thu, 9 Jan 2025 21:17:02 +0100 Subject: [PATCH] [UBSAN]Properly initialize datamembers for move operator --- SimDataFormats/GeneratorProducts/src/HepMCProduct.cc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/SimDataFormats/GeneratorProducts/src/HepMCProduct.cc b/SimDataFormats/GeneratorProducts/src/HepMCProduct.cc index 2de4e471aeb86..570d34f9f70ad 100644 --- a/SimDataFormats/GeneratorProducts/src/HepMCProduct.cc +++ b/SimDataFormats/GeneratorProducts/src/HepMCProduct.cc @@ -130,9 +130,9 @@ HepMCProduct::HepMCProduct(HepMCProduct const& other) : evt_(nullptr) { // swap void HepMCProduct::swap(HepMCProduct& other) { std::swap(evt_, other.evt_); - isVtxGenApplied_ = other.isVtxGenApplied_; - isVtxBoostApplied_ = other.isVtxBoostApplied_; - isPBoostApplied_ = other.isPBoostApplied_; + std::swap(isVtxGenApplied_, other.isVtxGenApplied_); + std::swap(isVtxBoostApplied_, other.isVtxBoostApplied_); + std::swap(isPBoostApplied_, other.isPBoostApplied_); } // assignment: use copy/swap idiom for exception safety. @@ -143,7 +143,10 @@ HepMCProduct& HepMCProduct::operator=(HepMCProduct const& other) { } // move, needed explicitly as we have raw pointer... -HepMCProduct::HepMCProduct(HepMCProduct&& other) : evt_(nullptr) { swap(other); } +HepMCProduct::HepMCProduct(HepMCProduct&& other) + : evt_(nullptr), isVtxGenApplied_(false), isVtxBoostApplied_(false), isPBoostApplied_(false) { + swap(other); +} HepMCProduct& HepMCProduct::operator=(HepMCProduct&& other) { swap(other); return *this;