Jinoh Kang (@iamahuman) commented about dlls/win32u/winstation.c:
+{
- if (!InterlockedDecrement( &session->ref ))
- {
NtUnmapViewOfSection( GetCurrentProcess(), (void *)session->shared );
free( session );
- }
+}
+static struct shared_session *get_shared_session( BOOL force ) +{
- struct shared_session *session;
- pthread_mutex_lock( &session_lock );
- if (!shared_session) force = TRUE;
- if (force && (session = calloc( 1, sizeof(*session) )))
If `calloc` fails, we crash anyway at line 118 (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 `session = calloc( 1, sizeof(*session) )` into the `if`-then body.
Precedent: https://gitlab.winehq.org/wine/wine/-/merge_requests/4152#note_52757