26 Jun
2024
26 Jun
'24
1:13 p.m.
Jinoh Kang (@iamahuman) commented about dlls/winecrt0/crt_dllmain.c:
+ LeaveCriticalSection( &onexit_cs ); + return ret; +} + BOOL WINAPI DllMainCRTStartup( HINSTANCE inst, DWORD reason, void *reserved ) { - return DllMain( inst, reason, reserved ); + BOOL ret; + + if (reason == DLL_PROCESS_ATTACH) _CRT_INIT(); + + ret = DllMain( inst, reason, reserved ); + + if (reason == DLL_PROCESS_DETACH) + { + while (onexit_end-- > onexit_begin) (**onexit_end)(); NULL pointer arithmetic is UB. Also, you should only do equality or inequality check with NULL.
```suggestion:-0+0 while (onexit_end != onexit_begin) (**--onexit_end)(); ``` -- https://gitlab.winehq.org/wine/wine/-/merge_requests/5809#note_74466