Skip to content

Commit

Permalink
Mallocator -> malloc, potential memory leak fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
denizzzka committed Oct 11, 2022
1 parent b0af370 commit 22ae5c5
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/dpq2/connection.d
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,14 @@ class Connection
version(Windows)
socket_t posixSocketDuplicate()
{
import std.experimental.allocator.mallocator: Mallocator;
import core.stdc.stdlib: malloc, free;
import core.sys.windows.winbase: GetCurrentProcessId;

static assert(socket_t.sizeof >= SOCKET.sizeof);

auto protocolInfo = cast(WSAPROTOCOL_INFOW*) Mallocator.instance.allocate(WSAPROTOCOL_INFOW.sizeof);
auto protocolInfo = cast(WSAPROTOCOL_INFOW*) malloc(WSAPROTOCOL_INFOW.sizeof);
scope(failure) free(protocolInfo);

int dupStatus = WSADuplicateSocketW(posixSocket, GetCurrentProcessId, protocolInfo);

if(dupStatus)
Expand Down

0 comments on commit 22ae5c5

Please sign in to comment.