0
0
mirror of https://github.com/OpenVPN/openvpn3.git synced 2024-09-20 04:02:15 +02:00

ringbuffer.hpp: fix SEH exception in destructor under debugger

When running under debugger, CloseHandle() throws SEH exception
when handle is already closed.

In this case handle was attempted to close twice -
first by destructor of WinEvent and then by destructor of
AsioEvent.

Fix by assigning duplicated handle to AsioEvent.

Reported-By: Anthony Wharton
Signed-off-by: Lev Stipakov <lev@openvpn.net>
This commit is contained in:
Lev Stipakov 2020-05-29 12:17:36 +03:00
parent 557ff6249b
commit 6473aeebe6
No known key found for this signature in database
GPG Key ID: 88670BE258B9C258

View File

@ -82,7 +82,11 @@ namespace openvpn
send_ring_ = (TUN_RING*)MapViewOfFile(send_ring_hmem(), FILE_MAP_ALL_ACCESS, 0, 0, sizeof(TUN_RING));
receive_ring_ = (TUN_RING*)MapViewOfFile(receive_ring_hmem(), FILE_MAP_ALL_ACCESS, 0, 0, sizeof(TUN_RING));
send_tail_moved_asio_event_.assign(send_ring_tail_moved_());
HANDLE handle;
DuplicateHandle(GetCurrentProcess(), send_ring_tail_moved_(),
GetCurrentProcess(), &handle, 0, FALSE, DUPLICATE_SAME_ACCESS);
send_tail_moved_asio_event_.assign(handle);
}
RingBuffer(openvpn_io::io_context& io_context,