diff options
author | Gurusamy Sarathy <gsar@cpan.org> | 2000-07-10 07:06:00 +0000 |
---|---|---|
committer | Gurusamy Sarathy <gsar@cpan.org> | 2000-07-10 07:06:00 +0000 |
commit | 4e94524934c1af4124b2888d9716e5304ee50ad9 (patch) | |
tree | f951c674084453812006f1be4f08cbf63b72c439 /win32/win32sck.c | |
parent | 0401f8415cd90e2eed98f1f8939fbc02af4a0c74 (diff) | |
download | perl-4e94524934c1af4124b2888d9716e5304ee50ad9.tar.gz |
accept() leaks memory on windows due to incorrect ordering of
closesocket() and fclose() calls
p4raw-id: //depot/perl@6328
Diffstat (limited to 'win32/win32sck.c')
-rw-r--r-- | win32/win32sck.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/win32/win32sck.c b/win32/win32sck.c index 2e4dc77825..043ad442fd 100644 --- a/win32/win32sck.c +++ b/win32/win32sck.c @@ -143,7 +143,7 @@ my_fdopen(int fd, char *mode) /* * If we get here, then fd is actually a socket. */ - Newz(1310, fp, 1, FILE); + Newz(1310, fp, 1, FILE); /* XXX leak, good thing this code isn't used */ if(fp == NULL) { errno = ENOMEM; return NULL; @@ -422,18 +422,19 @@ win32_socket(int af, int type, int protocol) int my_fclose (FILE *pf) { - int osf, retval; + int osf; if (!wsock_started) /* No WinSock? */ return(fclose(pf)); /* Then not a socket. */ osf = TO_SOCKET(fileno(pf));/* Get it now before it's gone! */ - retval = fclose(pf); /* Must fclose() before closesocket() */ if (osf != -1 && closesocket(osf) == SOCKET_ERROR && WSAGetLastError() != WSAENOTSOCK) { + (void)fclose(pf); return EOF; } - return retval; + else + return fclose(pf); } struct hostent * |