From 83def161de98f4eaaccf6c83b71644ef44cc384d Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 7 Mar 2007 10:46:38 -0500 Subject: Bug#25222 Win32 HANDLE leak in my_sopen() - When attempting to associate a Windows File handle to a C run-time file handle there is an upper bound. Once reached, the newly created handles will cause a memory leak since they are not properly associated with a handle that can later be cleaned up. mysys/my_open.c: Bug#25222 Win32 HANDLE leak in my_sopen() - Check for failure in _open_osfhandle and close allocated HANDLE on failure. --- mysys/my_open.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'mysys/my_open.c') diff --git a/mysys/my_open.c b/mysys/my_open.c index 2ba84f92ac2..9e1da1d3f07 100644 --- a/mysys/my_open.c +++ b/mysys/my_open.c @@ -345,7 +345,12 @@ File my_sopen(const char *path, int oflag, int shflag, int pmode) return -1; /* return error to caller */ } - fh= _open_osfhandle((intptr_t)osfh, oflag & (_O_APPEND | _O_RDONLY | _O_TEXT)); + if ((fh= _open_osfhandle((intptr_t)osfh, + oflag & (_O_APPEND | _O_RDONLY | _O_TEXT))) == -1) + { + _dosmaperr(GetLastError()); /* map error */ + CloseHandle(osfh); + } return fh; /* return handle */ } -- cgit v1.2.1