From 02cc80b30d5b5d6152171427ed8be8c8f91616e6 Mon Sep 17 00:00:00 2001 From: sneaxiy Date: Tue, 5 Jun 2018 10:33:20 +0800 Subject: [PATCH] Fix dangling pointer bug --- paddle/fluid/framework/executor.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/paddle/fluid/framework/executor.cc b/paddle/fluid/framework/executor.cc index 863053c32b..3d68c5fb87 100644 --- a/paddle/fluid/framework/executor.cc +++ b/paddle/fluid/framework/executor.cc @@ -220,8 +220,10 @@ void Executor::Run(const ProgramDesc& program, Scope* scope, has_fetch_operators(program.Block(0), *fetch_targets, fetch_holder_name); ProgramDesc* copy_program = const_cast(&program); + std::unique_ptr unique_ptr_of_copy_program; if (!has_feed_ops || !has_fetch_ops) { - copy_program = std::unique_ptr(new ProgramDesc(program)).get(); + unique_ptr_of_copy_program.reset(new ProgramDesc(program)); + copy_program = unique_ptr_of_copy_program.get(); } auto* global_block = copy_program->MutableBlock(0); -- GitLab