winpr: fixed incorrect pipe reference count usage
- refcount is only relevant for servermode
- refcount was used uninitialized in clientmode
- credit for fix goes to @bmiklautz
Bug was introduced by 5e09e37d42
This commit is contained in:
parent
2cca4c52fd
commit
538cc2d4a8
@ -234,7 +234,7 @@ HANDLE CreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
|
||||
|
||||
free(name);
|
||||
|
||||
pNamedPipe = (WINPR_NAMED_PIPE*) malloc(sizeof(WINPR_NAMED_PIPE));
|
||||
pNamedPipe = (WINPR_NAMED_PIPE*) calloc(1, sizeof(WINPR_NAMED_PIPE));
|
||||
hNamedPipe = (HANDLE) pNamedPipe;
|
||||
|
||||
WINPR_HANDLE_SET_TYPE(pNamedPipe, HANDLE_TYPE_NAMED_PIPE);
|
||||
|
@ -34,6 +34,8 @@
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "../handle/handle.h"
|
||||
|
||||
BOOL CloseHandle(HANDLE hObject)
|
||||
@ -167,27 +169,32 @@ BOOL CloseHandle(HANDLE hObject)
|
||||
|
||||
pipe = (WINPR_NAMED_PIPE*) Object;
|
||||
|
||||
if (--pipe->dwRefCount == 0)
|
||||
if (pipe->ServerMode)
|
||||
{
|
||||
pipe->pfnRemoveBaseNamedPipeFromList(pipe);
|
||||
assert(pipe->dwRefCount);
|
||||
|
||||
if (pipe->pBaseNamedPipe)
|
||||
if (--pipe->dwRefCount == 0)
|
||||
{
|
||||
CloseHandle((HANDLE) pipe->pBaseNamedPipe);
|
||||
pipe->pfnRemoveBaseNamedPipeFromList(pipe);
|
||||
|
||||
if (pipe->pBaseNamedPipe)
|
||||
{
|
||||
CloseHandle((HANDLE) pipe->pBaseNamedPipe);
|
||||
}
|
||||
}
|
||||
|
||||
if (pipe->clientfd != -1)
|
||||
close(pipe->clientfd);
|
||||
|
||||
if (pipe->serverfd != -1)
|
||||
close(pipe->serverfd);
|
||||
|
||||
free((char *)pipe->lpFileName);
|
||||
free((char *)pipe->lpFilePath);
|
||||
free((char *)pipe->name);
|
||||
free(pipe);
|
||||
}
|
||||
|
||||
if (pipe->clientfd != -1)
|
||||
close(pipe->clientfd);
|
||||
|
||||
if (pipe->serverfd != -1)
|
||||
close(pipe->serverfd);
|
||||
|
||||
free((char *)pipe->lpFileName);
|
||||
free((char *)pipe->lpFilePath);
|
||||
free((char *)pipe->name);
|
||||
free(pipe);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else if (Type == HANDLE_TYPE_ACCESS_TOKEN)
|
||||
|
Loading…
Reference in New Issue
Block a user