From a5c2d929c7aca5aa27a1d25ad293bf609dfaf40e Mon Sep 17 00:00:00 2001 From: ChrisCoxArt Date: Sat, 28 Feb 2026 18:08:19 -0800 Subject: [PATCH] Check range and observer for bogus input, before doing calculations fixes #621 --- IccProfLib/IccMatrixMath.cpp | 6 +++++- IccProfLib/IccPcc.cpp | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/IccProfLib/IccMatrixMath.cpp b/IccProfLib/IccMatrixMath.cpp index 40a7218d1..162708c88 100644 --- a/IccProfLib/IccMatrixMath.cpp +++ b/IccProfLib/IccMatrixMath.cpp @@ -356,6 +356,9 @@ bool CIccMatrixMath::SetRange(const icSpectralRange &srcRange, const icSpectralR if (m_nRows != dstRange.steps || m_nCols != srcRange.steps) return false; + if (srcRange.steps == 0) + return false; + icUInt16Number d; icFloatNumber srcStart = icF16toF(srcRange.start); icFloatNumber srcEnd = icF16toF(srcRange.end); @@ -367,7 +370,8 @@ bool CIccMatrixMath::SetRange(const icSpectralRange &srcRange, const icSpectralR icFloatNumber dstScale = (dstEnd - dstStart ) / (dstRange.steps - 1); icFloatNumber *data=entry(0); - memset(data, 0, dstRange.steps*srcRange.steps*sizeof(icFloatNumber)); + size_t dataSize = dstRange.steps * srcRange.steps * sizeof(icFloatNumber); + memset(data, 0, dataSize); for (d=0; dgetObserver(observerRange); + + // we can't do any calculations with this (non)observer + if (!observer || observerRange.steps == 0) + return NULL; if (!obs) obs = (icFloatNumber*)malloc(size*sizeof(icFloatNumber));