diff options
| author | İsa Yurdagül <[email protected]> | 2024-05-23 11:47:46 +0300 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-05-23 11:47:46 +0300 |
| commit | 59050f0d2a891f59987469ab79fe73411f5eb891 (patch) | |
| tree | 067c729d874b62790167041d682d87287ea9e5b6 | |
| parent | a0e28e02cbd274de30e64abd38d8690dd45396a9 (diff) | |
Issue of freeing memory without waiting completion of threads accessing it is fixed
| -rw-r--r-- | filesys/miniFilter/scanner/user/scanUser.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/filesys/miniFilter/scanner/user/scanUser.c b/filesys/miniFilter/scanner/user/scanUser.c index b4605156..82dc2fd5 100644 --- a/filesys/miniFilter/scanner/user/scanUser.c +++ b/filesys/miniFilter/scanner/user/scanUser.c @@ -151,6 +151,7 @@ Return Value { PSCANNER_NOTIFICATION notification; SCANNER_REPLY_MESSAGE replyMessage; + PSCANNER_MESSAGE message; LPOVERLAPPED pOvlp; BOOL result; DWORD outSize; @@ -265,13 +266,12 @@ main ( { DWORD requestCount = SCANNER_DEFAULT_REQUEST_COUNT; DWORD threadCount = SCANNER_DEFAULT_THREAD_COUNT; - HANDLE threads[SCANNER_MAX_THREAD_COUNT]; + HANDLE threads[SCANNER_MAX_THREAD_COUNT] = { NULL }; SCANNER_THREAD_CONTEXT context; HANDLE port, completion; PSCANNER_MESSAGE messages; DWORD threadId; HRESULT hr; - DWORD i, j; // // Check how many threads and per thread requests are desired. @@ -355,7 +355,7 @@ main ( // Create specified number of threads. // - for (i = 0; i < threadCount; i++) { + for (DWORD i = 0; i < threadCount; i++) { threads[i] = CreateThread( NULL, 0, @@ -375,7 +375,7 @@ main ( goto main_cleanup; } - for (j = 0; j < requestCount; j++) { + for (DWORD j = 0; j < requestCount; j++) { PSCANNER_MESSAGE msg = &(messages[i * requestCount + j]); @@ -397,11 +397,13 @@ main ( } hr = S_OK; - - WaitForMultipleObjectsEx( i, threads, TRUE, INFINITE, FALSE ); main_cleanup: + for (INT i = 0; threads[i] != NULL; ++i) { + WaitForSingleObjectEx(threads[i], INFINITE, FALSE); + } + printf( "Scanner: All done. Result = 0x%08x\n", hr ); CloseHandle( port ); |
