odin-lang / Odin

Odin Programming Language
https://odin-lang.org
BSD 3-Clause "New" or "Revised" License
6.89k stars 606 forks source link

[os2/file]: Fixes related to handle inheritance #3918

Closed flysand7 closed 3 months ago

flysand7 commented 3 months ago

On windows when a file was created using os2 functions, the .Close_On_Exec flag was forced onto the handle, even if it wasn't set by the user, forcing all handles to be non-inheritable in the _open() procedure. This PR makes all handles inheritable by default (same behavior as on linux), and fixes the bug where SECURITY_ATTRIBUTES struct was being used after free. Somehow after the scope ends, it was observied in the debugger that the pointer to the struct was being reset to nil, making it a valid parameter to CreateFile.