File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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);
You can’t perform that action at this time.
0 commit comments