From 0e835e8c0064e331a3af10bd3801a299672ce366 Mon Sep 17 00:00:00 2001 From: Lawrence Lee <45837045+Lawrence37@users.noreply.github.com> Date: Sun, 29 Oct 2023 16:20:12 -0700 Subject: [PATCH] Fix crash in noise reduction Fix upper bound for array access while building histogram of absolute values in mean absolute deviation (MAD) calculation. Fixes #6871. --- rtengine/FTblockDN.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rtengine/FTblockDN.cc b/rtengine/FTblockDN.cc index 7477c5d08..278c6806f 100644 --- a/rtengine/FTblockDN.cc +++ b/rtengine/FTblockDN.cc @@ -2106,7 +2106,7 @@ float ImProcFunctions::Mad(const float * DataList, const int datalen) //calculate histogram of absolute values of wavelet coeffs for (int i = 0; i < datalen; ++i) { - histo[static_cast(rtengine::min(32768.f, fabsf(DataList[i])))]++; + histo[static_cast(rtengine::min(32767.f, fabsf(DataList[i])))]++; } //find median of histogram