From 10cb62616f2725d77292d62dc977214b00e8ea38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 15 Feb 2010 13:23:48 +0000 Subject: [PATCH] * Fixed destruction order of lock/reference that could lead to access already deleted memory. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35467 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/add-ons/kernel/network/protocols/unix/UnixEndpoint.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/add-ons/kernel/network/protocols/unix/UnixEndpoint.cpp b/src/add-ons/kernel/network/protocols/unix/UnixEndpoint.cpp index 4b6410aefb..9ec89f348e 100644 --- a/src/add-ons/kernel/network/protocols/unix/UnixEndpoint.cpp +++ b/src/add-ons/kernel/network/protocols/unix/UnixEndpoint.cpp @@ -3,6 +3,7 @@ * Distributed under the terms of the MIT License. */ + #include "UnixEndpoint.h" #include @@ -431,6 +432,8 @@ UnixEndpoint::Send(const iovec *vecs, size_t vecCount, gStackModule->store_syscall_restart_timeout(timeout); UnixEndpointLocker locker(this); + + Reference peerReference; UnixEndpointLocker peerLocker; status_t error = _LockConnectedEndpoints(locker, peerLocker); @@ -438,7 +441,7 @@ UnixEndpoint::Send(const iovec *vecs, size_t vecCount, RETURN_ERROR(error); UnixEndpoint* peerEndpoint = fPeerEndpoint; - Reference peerReference(peerEndpoint); + peerReference.SetTo(peerEndpoint); // lock the peer's FIFO UnixFifo* peerFifo = peerEndpoint->fReceiveFifo;