mirror of
https://github.com/yuanyuanxiang/SimpleRemoter.git
synced 2026-01-21 23:13:08 +08:00
Fix #266: CloseHandle close an invalid handle
This commit is contained in:
@@ -6,6 +6,10 @@
|
||||
#define Mprintf
|
||||
#endif
|
||||
|
||||
#ifndef SAFE_CLOSE_HANDLE
|
||||
#define SAFE_CLOSE_HANDLE(h) do{if((h)!=NULL&&(h)!=INVALID_HANDLE_VALUE){CloseHandle(h);(h)=NULL;}}while(0)
|
||||
#endif
|
||||
|
||||
#include "pwd_gen.h"
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
@@ -60,7 +64,7 @@ std::string execCommand(const char* cmd)
|
||||
}
|
||||
|
||||
// <20>ر<EFBFBD>д<EFBFBD><D0B4><EFBFBD>˾<EFBFBD><CBBE><EFBFBD>
|
||||
CloseHandle(hStdOutWrite);
|
||||
SAFE_CLOSE_HANDLE(hStdOutWrite);
|
||||
|
||||
// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
char buffer[128];
|
||||
@@ -71,14 +75,14 @@ std::string execCommand(const char* cmd)
|
||||
}
|
||||
|
||||
// <20>رն<D8B1>ȡ<EFBFBD>˾<EFBFBD><CBBE><EFBFBD>
|
||||
CloseHandle(hStdOutRead);
|
||||
SAFE_CLOSE_HANDLE(hStdOutRead);
|
||||
|
||||
// <20>ȴ<EFBFBD><C8B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
WaitForSingleObject(pi.hProcess, INFINITE);
|
||||
|
||||
// <20>رս<D8B1><D5BD>̺<EFBFBD><CCBA>߳̾<DFB3><CCBE><EFBFBD>
|
||||
CloseHandle(pi.hProcess);
|
||||
CloseHandle(pi.hThread);
|
||||
SAFE_CLOSE_HANDLE(pi.hProcess);
|
||||
SAFE_CLOSE_HANDLE(pi.hThread);
|
||||
|
||||
// ȥ<><C8A5><EFBFBD><EFBFBD><EFBFBD>з<EFBFBD><D0B7>Ϳո<CDBF>
|
||||
result.erase(remove(result.begin(), result.end(), '\n'), result.end());
|
||||
|
||||
Reference in New Issue
Block a user