Skip to content

Commit 0d68aef

Browse files
committed
Wip double free
1 parent 9bb9cdb commit 0d68aef

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

eventstream_rpc/source/EventStreamClient.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,15 @@ namespace Aws
10241024
{
10251025
MessageAmendment connectAmendment(m_connectionConfig.GetConnectAmendment().value());
10261026
amendmentStorage.PrependHeaders(std::move(connectAmendment).GetHeaders());
1027-
amendmentStorage.SetPayload(std::move(connectAmendment).GetPayload());
1027+
1028+
// optional of a C structure is a terrible idea because it doesn't have a move which means
1029+
// a correct-looking move out of the optional does not actually erase the C struct, leading to a
1030+
// double free. For now, work around by copying the buffer and then erasing the source optional
1031+
// by hand.
1032+
amendmentStorage.SetPayload(connectAmendment.GetPayload());
1033+
1034+
Crt::Optional<Crt::ByteBuf> noBuffer;
1035+
connectAmendment.SetPayload(noBuffer);
10281036
}
10291037

10301038
s_fillNativeHeadersArray(amendmentStorage.GetHeaders(), headersArray, m_allocator);

0 commit comments

Comments
 (0)