Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Net/Net.CrossSslSocket.OpenSSL.pas
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,13 @@ procedure TCrossOpenSslConnection._SslSendInner(const ABuf: PByte;
if (LEncryptedData <> nil) then
begin
// 锁外发起异步发送, callback 内 CPS 继续推进 (新栈帧, 不在原栈上)
_Send(@LEncryptedData[0], Length(LEncryptedData),
// Use the TBytes overload so the buffer stays alive until the deferred
// send fires. The pointer overload does not copy and the callback closure
// does not capture LEncryptedData -- a use-after-free that's deterministic
// on macOS/Kqueue (allocator reuses the freed slot before transmit) and
// latent on Linux/Epoll and Windows/IOCP. Matches the canonical safe
// pattern documented in TCrossConnectionBase.SendBytes.
_Send(LEncryptedData,
procedure(const AConnection: ICrossConnection; const ASuccess: Boolean)
begin
if not ASuccess then
Expand Down