From: fca Date: Thu, 1 Dec 2011 10:07:06 +0000 (+0000) Subject: Coverity X-Git-Url: http://git.uio.no/git/?p=u%2Fmrichter%2FAliRoot.git;a=commitdiff_plain;h=19708f0f2b6ff7a8c759eb0d1a445f110ec5910e Coverity --- diff --git a/PWG2/FEMTOSCOPY/AliFemto/AliFemtoLorentzVector.h b/PWG2/FEMTOSCOPY/AliFemto/AliFemtoLorentzVector.h index e1a260d9bc1..17d41225139 100644 --- a/PWG2/FEMTOSCOPY/AliFemto/AliFemtoLorentzVector.h +++ b/PWG2/FEMTOSCOPY/AliFemto/AliFemtoLorentzVector.h @@ -450,9 +450,11 @@ template AliFemtoLorentzVector& AliFemtoLorentzVector::operator=(const AliFemtoLorentzVector& vec) { + if(this != &vec) { fThreeVector = vec.vect(); fX4 = vec.t(); - return *this; + } + return *this; } template diff --git a/PWG2/FEMTOSCOPY/AliFemto/AliFemtoThreeVector.h b/PWG2/FEMTOSCOPY/AliFemto/AliFemtoThreeVector.h index 41f6b99590f..e533c1b16fb 100644 --- a/PWG2/FEMTOSCOPY/AliFemto/AliFemtoThreeVector.h +++ b/PWG2/FEMTOSCOPY/AliFemto/AliFemtoThreeVector.h @@ -504,8 +504,10 @@ template inline AliFmThreeVector& AliFmThreeVector::operator=(const AliFmThreeVector& v) { + if(this != &v) { mX1 = v.x(); mX2 = v.y(); mX3 = v.z(); - return *this; + } + return *this; } template diff --git a/PWG2/FEMTOSCOPY/AliFemtoUser/AliFemtoModelAllHiddenInfo.cxx b/PWG2/FEMTOSCOPY/AliFemtoUser/AliFemtoModelAllHiddenInfo.cxx index d7c22f4c941..5f462c9754f 100644 --- a/PWG2/FEMTOSCOPY/AliFemtoUser/AliFemtoModelAllHiddenInfo.cxx +++ b/PWG2/FEMTOSCOPY/AliFemtoUser/AliFemtoModelAllHiddenInfo.cxx @@ -34,59 +34,47 @@ AliFemtoModelAllHiddenInfo::AliFemtoModelAllHiddenInfo() : //_____________________________________________ AliFemtoModelAllHiddenInfo::AliFemtoModelAllHiddenInfo(const AliFemtoModelAllHiddenInfo &aInfo) : AliFemtoModelHiddenInfo(aInfo), - fTrueMomentumMother(0), - fEmissionPointMother(0), - fPDGPidMother(0), - fTrueMomentumChild1(0), - fTrueMomentumChild2(0), - fPDGPidChild1(0), - fPDGPidChild2(0) + fTrueMomentumMother(new AliFemtoLorentzVector(*(aInfo.fTrueMomentumMother))), + fEmissionPointMother(new AliFemtoLorentzVector(*(aInfo.fEmissionPointMother))), + fPDGPidMother(aInfo.fPDGPidMother), + fTrueMomentumChild1(new AliFemtoLorentzVector(*(aInfo.fTrueMomentumChild1))), + fTrueMomentumChild2(new AliFemtoLorentzVector(*(aInfo.fTrueMomentumChild2))), + fPDGPidChild1(aInfo.fPDGPidChild1), + fPDGPidChild2(aInfo.fPDGPidChild2) { + // // Copy constructor - if (aInfo.GetTrueMomentumMother()) - SetTrueMomentumMother(aInfo.GetTrueMomentumMother()); - if (aInfo.GetEmissionPointMother()) - SetEmissionPointMother(aInfo.GetEmissionPointMother()); - fPDGPidMother = aInfo.GetPDGPidMother(); - if (aInfo.GetTrueMomentumChild1()) - SetTrueMomentumChild1(aInfo.GetTrueMomentumChild1()); - if (aInfo.GetTrueMomentumChild2()) - SetTrueMomentumChild2(aInfo.GetTrueMomentumChild2()); - fPDGPidChild1 = aInfo.GetPDGPidChild1(); - fPDGPidChild2 = aInfo.GetPDGPidChild2(); + // } //_____________________________________________ AliFemtoModelAllHiddenInfo::~AliFemtoModelAllHiddenInfo() { // Destructor - if (fTrueMomentumMother) delete fTrueMomentumMother; - if (fEmissionPointMother) delete fEmissionPointMother; - if (fTrueMomentumChild1) delete fTrueMomentumChild1; - if (fTrueMomentumChild2) delete fTrueMomentumChild2; + delete fTrueMomentumMother; + delete fEmissionPointMother; + delete fTrueMomentumChild1; + delete fTrueMomentumChild2; } //_____________________________________________ AliFemtoModelAllHiddenInfo& AliFemtoModelAllHiddenInfo::operator=(const AliFemtoModelAllHiddenInfo& aInfo) { + // // assignment operator - if (this == &aInfo) - return *this; - - if (aInfo.GetTrueMomentumMother()) - SetTrueMomentumMother(aInfo.GetTrueMomentumMother()); - else SetTrueMomentumMother(0); - if (aInfo.GetEmissionPointMother()) - SetEmissionPointMother(aInfo.GetEmissionPointMother()); - else SetEmissionPointMother(0); - fPDGPidMother = aInfo.GetPDGPidMother(); - if (aInfo.GetTrueMomentumChild1()) - SetTrueMomentumChild1(aInfo.GetTrueMomentumChild1()); - else SetTrueMomentumChild1(0); - if (aInfo.GetTrueMomentumChild2()) - SetTrueMomentumChild2(aInfo.GetTrueMomentumChild2()); - else SetTrueMomentumChild2(0); - fPDGPidChild1 = aInfo.GetPDGPidChild1(); - fPDGPidChild2 = aInfo.GetPDGPidChild2(); - + // + if (this != &aInfo) { + AliFemtoModelHiddenInfo::operator=(aInfo); + delete fTrueMomentumMother; + fTrueMomentumMother = new AliFemtoLorentzVector(*(aInfo.fTrueMomentumMother)); + delete fEmissionPointMother; + fEmissionPointMother = new AliFemtoLorentzVector(*(aInfo.fEmissionPointMother)); + fPDGPidMother = aInfo.fPDGPidMother; + delete fTrueMomentumChild1; + fTrueMomentumChild1 = new AliFemtoLorentzVector(*(aInfo.fTrueMomentumChild1)); + delete fTrueMomentumChild2; + fTrueMomentumChild2 = new AliFemtoLorentzVector(*(aInfo.fTrueMomentumChild2)); + fPDGPidChild1 = aInfo.fPDGPidChild1; + fPDGPidChild2 = aInfo.fPDGPidChild2; + } return *this; } //