Skip to content

Commit

Permalink
Re #7876. Delete right before new allocation.
Browse files Browse the repository at this point in the history
The coverity scan complained that the deleted fitter could be used at
line 234 if all the if tests above it were false. Don't know if that
can happen, but let's be safe.
  • Loading branch information
RussellTaylor committed Sep 5, 2013
1 parent f7597b9 commit d93cba1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Code/Mantid/MantidPlot/src/ExpDecayDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,26 +207,26 @@ void ExpDecayDialog::fit()

int precision = app->fit_output_precision;

if (fitter)
delete fitter;

if (slopes == 3)
{
double x_init[7] = {1.0, boxFirst->text().toDouble(), 1.0, boxSecond->text().toDouble(),
1.0, boxThird->text().toDouble(), boxYOffset->text().toDouble()};
delete fitter;
fitter = new ThreeExpFit(app, graph);
fitter->setInitialGuesses(x_init);
}
else if (slopes == 2)
{
double x_init[5] = {1.0, boxFirst->text().toDouble(), 1.0, boxSecond->text().toDouble(),
boxYOffset->text().toDouble()};
delete fitter;
fitter = new TwoExpFit(app, graph);
fitter->setInitialGuesses(x_init);
}
else if (slopes == 1 || slopes == -1)
{
double x_init[3] = {boxAmplitude->text().toDouble(), slopes/boxFirst->text().toDouble(), boxYOffset->text().toDouble()};
delete fitter;
fitter = new ExponentialFit(app, graph, slopes == -1);
fitter->setInitialGuesses(x_init);
}
Expand Down

0 comments on commit d93cba1

Please sign in to comment.