From 1cae3d60e6bf8df3405d9070f0e85f9e44c44bd9 Mon Sep 17 00:00:00 2001 From: Omar Emara Date: Fri, 16 Feb 2024 10:51:36 +0200 Subject: [PATCH] Fix #118344: Crash when File Output node has no input The File Output node crashes if it has no image input. That's because we would be attempting to save a zero sized image. So ensure that the node has a non zero canvas before saving anything. --- .../operations/COM_FileOutputOperation.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/source/blender/compositor/operations/COM_FileOutputOperation.cc b/source/blender/compositor/operations/COM_FileOutputOperation.cc index 8d894bac6d4..01c33d995c8 100644 --- a/source/blender/compositor/operations/COM_FileOutputOperation.cc +++ b/source/blender/compositor/operations/COM_FileOutputOperation.cc @@ -147,6 +147,19 @@ static void add_meta_data_for_input(realtime_compositor::FileOutput &file_output void FileOutputOperation::deinit_execution() { + /* It is possible that none of the inputs would have an image connected, which will materialize + * as a size of zero, so check this here and return early doing nothing. Just make sure to free + * the allocated buffers. */ + const int2 size = int2(get_width(), get_height()); + if (size == int2(0)) { + for (const FileOutputInput &input : file_output_inputs_) { + if (input.output_buffer) { + MEM_freeN(input.output_buffer); + } + } + return; + } + if (is_multi_layer()) { execute_multi_layer(); }