Jinoh Kang (@iamahuman) commented about dlls/win32u/winstation.c:
+void shared_desktop_release( struct shared_desktop *desktop ) +{
- if (!InterlockedDecrement( &desktop->ref ))
- {
shared_session_release( desktop->session );
free( desktop );
- }
+}
+struct shared_desktop *get_shared_desktop( BOOL force ) +{
- struct user_thread_info *thread_info = get_user_thread_info();
- struct shared_desktop *desktop;
- if (!thread_info->shared_desktop) force = TRUE;
- if (force && (desktop = calloc( 1, sizeof(*desktop) )))
If `calloc` fails, we crash anyway at line 189 (since `thread_info->shared_desktop == NULL`). Checking for NULL here gives false illusion that we care, when we actually don't.
We should just move `desktop = calloc( 1, sizeof(*desktop) )` into the `if`-then body.
Precedent: https://gitlab.winehq.org/wine/wine/-/merge_requests/4152#note_52757