Skip to content

Commit 8164a75

Browse files
authored
Merge pull request #11176 from sneaxiy/zjl-dev
Fix dangling pointer bug in paddle/fluid/framework/executor.cc
2 parents f2c5574 + 02cc80b commit 8164a75

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

paddle/fluid/framework/executor.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,10 @@ void Executor::Run(const ProgramDesc& program, Scope* scope,
220220
has_fetch_operators(program.Block(0), *fetch_targets, fetch_holder_name);
221221

222222
ProgramDesc* copy_program = const_cast<ProgramDesc*>(&program);
223+
std::unique_ptr<ProgramDesc> unique_ptr_of_copy_program;
223224
if (!has_feed_ops || !has_fetch_ops) {
224-
copy_program = std::unique_ptr<ProgramDesc>(new ProgramDesc(program)).get();
225+
unique_ptr_of_copy_program.reset(new ProgramDesc(program));
226+
copy_program = unique_ptr_of_copy_program.get();
225227
}
226228

227229
auto* global_block = copy_program->MutableBlock(0);

0 commit comments

Comments
 (0)