From 3aa699a8d3f03c766a4410b31998f5ac5f02f1f0 Mon Sep 17 00:00:00 2001 From: YimingWu Date: Fri, 19 Apr 2024 09:59:59 +0800 Subject: [PATCH] Fix #120806: Clamp gamma when passed to OIIO Enabling vector scope/histogram when gamma is set too low will crash OIIO, the exponent value (1/gamma) is limited to 100 by OIIO, so clamping this value before passing to OIIO to prevent such error. --- source/blender/imbuf/intern/colormanagement.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/blender/imbuf/intern/colormanagement.cc b/source/blender/imbuf/intern/colormanagement.cc index 9e0cae61824..5c9222b8269 100644 --- a/source/blender/imbuf/intern/colormanagement.cc +++ b/source/blender/imbuf/intern/colormanagement.cc @@ -881,7 +881,10 @@ static OCIO_ConstCPUProcessorRcPtr *create_display_buffer_processor(const char * OCIO_ConstConfigRcPtr *config = OCIO_getCurrentConfig(); const bool use_look = colormanage_use_look(look, view_transform); const float scale = (exposure == 0.0f) ? 1.0f : powf(2.0f, exposure); - const float exponent = (gamma == 1.0f) ? 1.0f : 1.0f / max_ff(FLT_EPSILON, gamma); + float exponent = (gamma == 1.0f) ? 1.0f : 1.0f / max_ff(FLT_EPSILON, gamma); + if (exponent > 100.0f) { + exponent = 100.0f; + } OCIO_ConstProcessorRcPtr *processor = OCIO_createDisplayProcessor(config, from_colorspace, -- 2.30.2