From d8f265660575928d279a007a7540dedf63d154b4 Mon Sep 17 00:00:00 2001 From: ChrisCoxArt Date: Tue, 24 Feb 2026 17:50:51 -0800 Subject: [PATCH] don't run over the end of the array when testing sel/case statements Fixes #617 --- IccProfLib/IccMpeCalc.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/IccProfLib/IccMpeCalc.cpp b/IccProfLib/IccMpeCalc.cpp index 90cf8a88b..9a9819bed 100644 --- a/IccProfLib/IccMpeCalc.cpp +++ b/IccProfLib/IccMpeCalc.cpp @@ -3658,10 +3658,12 @@ bool CIccCalculatorFunc::InitSelectOp(SIccCalcOp *ops, icUInt32Number nOps) if (ops->extra) return true; - icUInt32Number i, n, pos; - for (n=0; nextra=n; + for (n=0; n<(nOps-1) && ops[n+1].sig==icSigCaseOp; n++); + if (n >= (nOps-1)) // there are no operations after the cases, and we don't want a segfault + return false; + + ops->extra = n; if (ops[n+1].sig==icSigDefaultOp) { n++; }