Jinoh Kang (@iamahuman) commented about programs/regsvr32/regsvr32.c:
static BOOL Silent = FALSE;
+/* This program is actually defined in GUI subsystem, but still wants
- to print to Unix console if available.
- */
+static void wine_console_write(const WCHAR* str) +{
- static HANDLE output_handle;
- static UINT output_codepage = (UINT)-1;
- if (output_codepage == (UINT)-1)
- {
wine_server_fd_to_handle(1, GENERIC_WRITE | SYNCHRONIZE, OBJ_INHERIT, &output_handle);
The output handle is marked inheritable, but child processes won't know about the handle. Making it inheritable will thus lead to "handle leak."
```suggestion:-0+0 wine_server_fd_to_handle(1, GENERIC_WRITE | SYNCHRONIZE, 0, &output_handle); ```
Contrast this with other uses of `wine_server_fd_to_handle( {0,1,2}, ..., OBJ_INHERIT, &... )`[^1][^2], which explicitly uses the allocated handle for std handles in process parameters. Note that wineserver assumes that std handles are inheritable[^3].
[^1]: https://gitlab.winehq.org/wine/wine/-/blob/7c45c7c5ebb59237d568a4e5b38626422e670b63/dlls/ntdll/unix/env.c#L1382-1384 [^2]: https://gitlab.winehq.org/wine/wine/-/blob/7c45c7c5ebb59237d568a4e5b38626422e670b63/dlls/ntdll/unix/env.c#L1619 [^3]: https://gitlab.winehq.org/wine/wine/-/blob/7c45c7c5ebb59237d568a4e5b38626422e670b63/server/process.c#L1336-1347