From 7ab29dca081cf7f2cb04de49e243d1d8d7940d45 Mon Sep 17 00:00:00 2001 From: ChrisCoxArt Date: Sat, 14 Mar 2026 19:36:55 -0700 Subject: [PATCH] check m_pCalc input and output count before calling it Fixes #678 --- IccProfLib/IccMpeBasic.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/IccProfLib/IccMpeBasic.cpp b/IccProfLib/IccMpeBasic.cpp index 7b5977a91..7d2a7a1c1 100644 --- a/IccProfLib/IccMpeBasic.cpp +++ b/IccProfLib/IccMpeBasic.cpp @@ -2355,6 +2355,10 @@ bool CIccSampledCalculatorCurve::Begin(icElemInterp nInterp, CIccTagMultiProcess if (m_nDesiredSize < 2 || !m_pCalc || !m_pCalc->Begin(nInterp, pMPE)) return false; + // if these fail, then we would overrun the src and dest stack variables below + if (m_pCalc->NumOutputChannels() != 1 || m_pCalc->NumInputChannels() != 1) + return false; + icUInt32Number nSize = m_nDesiredSize; if (nSize < 2) nSize = 2; @@ -2377,7 +2381,7 @@ bool CIccSampledCalculatorCurve::Begin(icElemInterp nInterp, CIccTagMultiProcess icFloatNumber src, dst; src = (icFloatNumber)i / m_last * m_range + m_firstEntry; - m_pCalc->Apply(pApply, &dst, &src); + m_pCalc->Apply(pApply, &dst, &src); // m_pCalc must be 1 input, 1 output! m_pSamples[i] = dst; }