Skip to content

Commit 4e348bf

Browse files
authored
[orc-rt] Fix memory leak in WrapperFunctionResult. (#156795)
Previously `Tmp` could have been left owning a heap-allocated buffer and would not have freed it on destruction (since Tmp was a C orc_rt_WrapperFunctionResult). This patch removes Tmp and simply resets R before swapping it with Other.R.
1 parent a95edec commit 4e348bf

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

orc-rt/include/orc-rt/WrapperFunctionResult.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,9 @@ class WrapperFunctionResult {
4040
}
4141

4242
WrapperFunctionResult &operator=(WrapperFunctionResult &&Other) {
43-
orc_rt_WrapperFunctionResult Tmp;
44-
orc_rt_WrapperFunctionResultInit(&Tmp);
45-
std::swap(Tmp, Other.R);
46-
std::swap(R, Tmp);
43+
orc_rt_DisposeWrapperFunctionResult(&R);
44+
orc_rt_WrapperFunctionResultInit(&R);
45+
std::swap(R, Other.R);
4746
return *this;
4847
}
4948

0 commit comments

Comments
 (0)