From 320c2e8878933e761a55d352e4603d97c53fcfa1 Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Fri, 21 Jun 2024 10:22:42 +0200 Subject: [PATCH] Fix: Compositor crash when second image of Mix node is missing The first input of the compositor Mix node determines resolution, leading to situation when the second input will always be attempted to be evaluated. If the first input is a longer image sequence than the second input it leads to a crash. Do a null-pointer check and return transparent image in this cases, similar to what the Movie Clip operation is doing. Pull Request: https://projects.blender.org/blender/blender/pulls/123493 --- .../compositor/operations/COM_ImageOperation.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/source/blender/compositor/operations/COM_ImageOperation.cc b/source/blender/compositor/operations/COM_ImageOperation.cc index 47bacff3085..4ba20d90fa8 100644 --- a/source/blender/compositor/operations/COM_ImageOperation.cc +++ b/source/blender/compositor/operations/COM_ImageOperation.cc @@ -82,14 +82,24 @@ void ImageOperation::update_memory_buffer_partial(MemoryBuffer *output, { const bool ensure_premultiplied = !ELEM( image_->alpha_mode, IMA_ALPHA_CHANNEL_PACKED, IMA_ALPHA_IGNORE); - output->copy_from(buffer_, area, ensure_premultiplied, true); + if (buffer_) { + output->copy_from(buffer_, area, ensure_premultiplied, true); + } + else { + output->fill(area, COM_COLOR_TRANSPARENT); + } } void ImageAlphaOperation::update_memory_buffer_partial(MemoryBuffer *output, const rcti &area, Span /*inputs*/) { - output->copy_from(buffer_, area, 3, COM_DATA_TYPE_VALUE_CHANNELS, 0); + if (buffer_) { + output->copy_from(buffer_, area, 3, COM_DATA_TYPE_VALUE_CHANNELS, 0); + } + else { + output->fill(area, COM_VALUE_ZERO); + } } } // namespace blender::compositor