Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmar Emara <mail@OmarEmara.dev>2022-04-07 13:23:25 +0300
committerOmar Emara <mail@OmarEmara.dev>2022-04-07 13:23:25 +0300
commitd4efcef5e303eae1be9c6d7e1dc17f72a9a71252 (patch)
tree1b7ba3b347c976ba226662ad074788564c8b9287
parent09d6ce320f4fda04bce2baf806a3f8c71677f72e (diff)
Viewport Compositor: Fix use after free results
-rw-r--r--source/blender/nodes/NOD_compositor_execute.hh5
-rw-r--r--source/blender/nodes/intern/node_compositor_execute.cc6
2 files changed, 6 insertions, 5 deletions
diff --git a/source/blender/nodes/NOD_compositor_execute.hh b/source/blender/nodes/NOD_compositor_execute.hh
index 4463db979cc..5c0591db5bc 100644
--- a/source/blender/nodes/NOD_compositor_execute.hh
+++ b/source/blender/nodes/NOD_compositor_execute.hh
@@ -4,6 +4,7 @@
#pragma once
#include <cstdint>
+#include <memory>
#include "BLI_map.hh"
#include "BLI_math_vec_types.hh"
@@ -567,8 +568,8 @@ class NodeOperation : public Operation {
private:
/* The node that this operation represents. */
DNode node_;
- /* A vector storing the results mapped to the inputs that are not linked. */
- Vector<Result> unlinked_inputs_results_;
+ /* A vector storing unique pointers to the results mapped to unlinked inputs. */
+ Vector<std::unique_ptr<Result>> unlinked_inputs_results_;
/* A mapping between each unlinked input in the node identified by its identifier and its
* corresponding input socket. */
Map<StringRef, DInputSocket> unlinked_inputs_sockets_;
diff --git a/source/blender/nodes/intern/node_compositor_execute.cc b/source/blender/nodes/intern/node_compositor_execute.cc
index 3d1cb671486..ecd3d807098 100644
--- a/source/blender/nodes/intern/node_compositor_execute.cc
+++ b/source/blender/nodes/intern/node_compositor_execute.cc
@@ -2,6 +2,7 @@
* Copyright 2022 Blender Foundation. All rights reserved. */
#include <limits>
+#include <memory>
#include <string>
#include "BLI_assert.h"
@@ -697,9 +698,8 @@ void NodeOperation::populate_results_for_unlinked_inputs()
/* Construct a result of an appropriate type, add it to the results vector, and map the input
* to it. */
const ResultType result_type = get_node_socket_result_type(origin.socket_ref());
- const Result result = Result(result_type, texture_pool());
- unlinked_inputs_results_.append(result);
- map_input_to_result(input->identifier(), &unlinked_inputs_results_.last());
+ unlinked_inputs_results_.append(std::make_unique<Result>(result_type, texture_pool()));
+ map_input_to_result(input->identifier(), unlinked_inputs_results_.last().get());
/* Map the input to the socket to later allocate and initialize its value. */
const DInputSocket origin_input{origin.context(), &origin->as_input()};