Prevent crash when color management is turned off

Prevent a segmentation fault when the viewport is set to 'Material Preview'
mode, drawing textures, and Blender built with `WITH_OPENCOLORIO=OFF`.

Most `IMB_colormanagement_...` functions assume that the `colorspace`
pointer can be `nullptr`, but the internal function
`colormanage_ensure_srgb_scene_linear_info()` does not, causing a crash.

Since this check can be done in multiple places, I picked one that seems
consistent with the rest of the code.

Pull Request: https://projects.blender.org/blender/blender/pulls/111144
This commit is contained in:
Sybren A. Stüvel
2023-08-17 10:21:09 +02:00
parent f44447a628
commit 0e2875ede9

View File

@@ -1355,7 +1355,7 @@ bool IMB_colormanagement_space_is_data(ColorSpace *colorspace)
static void colormanage_ensure_srgb_scene_linear_info(ColorSpace *colorspace)
{
if (!colorspace->info.cached) {
if (colorspace && !colorspace->info.cached) {
OCIO_ConstConfigRcPtr *config = OCIO_getCurrentConfig();
OCIO_ConstColorSpaceRcPtr *ocio_colorspace = OCIO_configGetColorSpace(config,
colorspace->name);