Commit 83def161 authored by unknown's avatar unknown
Browse files

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.
parent c4390d05
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -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 */
}