Skip to content

Commit

Permalink
fix: thread handle leak.
Browse files Browse the repository at this point in the history
  • Loading branch information
ufrisk committed Sep 15, 2019
1 parent 4d11c5b commit 184a026
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion leechcore/device_usb3380.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,16 @@ PTHREAD_DATA_READ_EP ReadScatterGather_Thread3_Collect(_In_ BOOL fAll)

VOID ReadScatterGather_Thread3_Queue(_Inout_ PPMEM_IO_SCATTER_HEADER ppMEMs, _In_ DWORD cpMEMs, _In_ DWORD pa, _In_ DWORD cb)
{
HANDLE hThread;
PTHREAD_DATA_READ_EP ptd = ReadScatterGather_Thread3_Collect(FALSE);
ptd->isFinished = FALSE;
ptd->result = FALSE;
ptd->pa = pa;
ptd->cb = cb;
ptd->ppMEMs = ppMEMs;
ptd->cpMEMs = cpMEMs;
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Device3380_ReadDMA2, ptd, 0, NULL);
hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)Device3380_ReadDMA2, ptd, 0, NULL);
if(hThread) { CloseHandle(hThread); }
}

VOID ReadScatterGather_Thread3(_Inout_ PPMEM_IO_SCATTER_HEADER ppMEMs, _In_ DWORD cpMEMs, _In_ DWORD cbThreadLimit)
Expand Down
4 changes: 3 additions & 1 deletion leechcore/leechrpcclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ BOOL LeechRPC_Open(_In_ BOOL fIsRpc)
LPSTR szArg1, szArg2, szArg3;
LPSTR szOpt[3];
DWORD i, dwPort = 0;
HANDLE hThread;
int(*pfn_printf_opt_tmp)(_In_z_ _Printf_format_string_ char const* const _Format, ...);
ctx = (PLEECHRPC_CLIENT_CONTEXT)LocalAlloc(LMEM_ZEROINIT, sizeof(LEECHRPC_CLIENT_CONTEXT));
if(!ctx) { return FALSE; }
Expand Down Expand Up @@ -603,7 +604,8 @@ BOOL LeechRPC_Open(_In_ BOOL fIsRpc)
vprintfv("RPC: INFO: Compression disabled.\n");
}
// all ok - initialize this rpc device stub.
CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)LeechRPC_KeepaliveThreadClient, NULL, 0, NULL);
hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)LeechRPC_KeepaliveThreadClient, NULL, 0, NULL);
if(hThread) { CloseHandle(hThread); hThread = 0; }
strncpy_s(pMsgRsp->cfg.szRemote, sizeof(pMsgRsp->cfg.szRemote), ctxDeviceMain->cfg.szRemote, _TRUNCATE); // ctx from remote doesn't contain remote info ...
pfn_printf_opt_tmp = ctxDeviceMain->cfg.pfn_printf_opt;
memcpy(&ctxDeviceMain->cfg, &pMsgRsp->cfg, sizeof(LEECHCORE_CONFIG));
Expand Down

0 comments on commit 184a026

Please sign in to comment.