From 0b807d5d77fd92287af58940a81df6f13c0e519e Mon Sep 17 00:00:00 2001 From: Federico Montesino Pouzols <federico.montesino-pouzols@stfc.ac.uk> Date: Tue, 13 Oct 2015 17:34:37 +0100 Subject: [PATCH] check non-neg return from find() before indexing, 1301227, re #13951 --- .../Crystal/src/IntegratePeakTimeSlices.cpp | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/Framework/Crystal/src/IntegratePeakTimeSlices.cpp b/Framework/Crystal/src/IntegratePeakTimeSlices.cpp index 263ca543401..9828bea2f54 100644 --- a/Framework/Crystal/src/IntegratePeakTimeSlices.cpp +++ b/Framework/Crystal/src/IntegratePeakTimeSlices.cpp @@ -587,6 +587,12 @@ void IntegratePeakTimeSlices::exec() { // Now set up the center for this peak int i = find("Mrow", names); + if (i < 0) { + throw std::runtime_error("Inconsistency found in algorithm " + "execution. The index for the parameter " + "Mrow is negative."); + } + lastRow = (int)(params[i] + .5); i = find("Mcol", names); lastCol = (int)(params[i] + .5); @@ -2221,13 +2227,15 @@ bool IntegratePeakTimeSlices::isGoodFit(std::vector<double> const ¶ms, double chisqOverDOF) { int Ibk = find("Background", names); if (Ibk < 0) - throw runtime_error("Irrecoverable inconsistency found. The index for the " - "parameter 'Background' is lower than zero."); + throw std::runtime_error( + "Irrecoverable inconsistency found. The index for the " + "parameter 'Background' is lower than zero."); int IIntensity = find("Intensity", names); if (IIntensity < 0) - throw runtime_error("Irrecoverable inconsistency found. The index for the " - "parameter 'Intensity' is lower than zero."); + throw std::runtime_error( + "Irrecoverable inconsistency found. The index for the " + "parameter 'Intensity' is lower than zero."); if (chisqOverDOF < 0) { @@ -2505,6 +2513,15 @@ int IntegratePeakTimeSlices::UpdateOutputWS( int Irow = find("Mrow", names); int Icol = find("Mcol", names); + if (Ibk < 0 || IIntensity < 0 || IVx < 0 || IVy < 0 || IVxy < 0 || Irow < 0 || + Icol < 0) { + throw std::runtime_error("Inconsistency found when updating output " + "workspace. None of the indices for the " + "parameters 'Background', 'Intensity', 'SScol', " + "'SSrow', 'SSrc', 'Mrow', 'Mcol' can be " + "negative."); + } + int newRowIndex = 0; if (dir > 0) -- GitLab