From 97def841224744b37c4f6e0bd0291f2b7075748c Mon Sep 17 00:00:00 2001 From: hristov Date: Mon, 31 Jan 2011 11:44:21 +0000 Subject: [PATCH] Fix for Coverity defect 14107: RESOURCE_LEAK --- STEER/AliBaseCalibViewer.cxx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/STEER/AliBaseCalibViewer.cxx b/STEER/AliBaseCalibViewer.cxx index 39f07266494..1b2ce08724c 100644 --- a/STEER/AliBaseCalibViewer.cxx +++ b/STEER/AliBaseCalibViewer.cxx @@ -243,7 +243,10 @@ TString* AliBaseCalibViewer::Fit(const Char_t* drawCommand, const Char_t* formul fitter->ClearPoints(); Int_t entries = Draw(drawStr.Data(), cutStr.Data(), "goff"); - if (entries == -1) return new TString("An ERROR has occured during fitting!"); + if (entries == -1) { + delete fitter; + return new TString("An ERROR has occured during fitting!"); + } Double_t **values = new Double_t*[dim+1] ; for (Int_t i = 0; i < dim + 1; i++){ @@ -251,7 +254,11 @@ TString* AliBaseCalibViewer::Fit(const Char_t* drawCommand, const Char_t* formul if (i < dim) centries = fTree->Draw(((TObjString*)formulaTokens->At(i))->GetName(), cutStr.Data(), "goff"); else centries = fTree->Draw(drawStr.Data(), cutStr.Data(), "goff"); - if (entries != centries) return new TString("An ERROR has occured during fitting!"); + if (entries != centries) { + delete fitter; + delete [] values; + return new TString("An ERROR has occured during fitting!"); + } values[i] = new Double_t[entries]; memcpy(values[i], fTree->GetV1(), entries*sizeof(Double_t)); } @@ -278,6 +285,7 @@ TString* AliBaseCalibViewer::Fit(const Char_t* drawCommand, const Char_t* formul returnFormula.Append(" )"); delete formulaTokens; delete fitter; + for (Int_t i = 0; i < dim + 1; i++) delete [] values[i]; delete[] values; return preturnFormula; } -- 2.39.3