From 58b9dcd6eeda1663c6bfa4263c681c018ab151be Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Tue, 14 Dec 2021 12:07:01 +0100 Subject: [PATCH 1/7] Indentation correction of Windows specific utility functions The corrections refer to the following commits, so that they are not mixed up with blank changes. Signed-off-by: Ralf Habacker --- dbus/dbus-sysdeps-win.c | 83 +++++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 41 deletions(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 43350cc7..de016c41 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -2935,62 +2935,62 @@ static const char *cDBusDaemonMutex = "DBusDaemonMutex"; static const char *cDBusDaemonAddressInfo = "DBusDaemonAddressInfo"; static dbus_bool_t -_dbus_get_install_root_as_hash(DBusString *out) +_dbus_get_install_root_as_hash (DBusString *out) { - DBusString install_path; + DBusString install_path; - _dbus_string_init(&install_path); + _dbus_string_init (&install_path); - if (!_dbus_get_install_root (&install_path) || - _dbus_string_get_length (&install_path) == 0) - return FALSE; + if (!_dbus_get_install_root (&install_path) || + _dbus_string_get_length (&install_path) == 0) + return FALSE; - _dbus_string_init(out); - _dbus_string_tolower_ascii(&install_path,0,_dbus_string_get_length(&install_path)); + _dbus_string_init (out); + _dbus_string_tolower_ascii (&install_path, 0, _dbus_string_get_length (&install_path)); - if (!_dbus_sha_compute (&install_path, out)) - return FALSE; + if (!_dbus_sha_compute (&install_path, out)) + return FALSE; - return TRUE; + return TRUE; } static dbus_bool_t _dbus_get_address_string (DBusString *out, const char *basestring, const char *scope) { - _dbus_string_init(out); - _dbus_string_append(out,basestring); + _dbus_string_init (out); + _dbus_string_append (out, basestring); if (!scope) { return TRUE; } - else if (strcmp(scope,"*install-path") == 0 + else if (strcmp (scope, "*install-path") == 0 // for 1.3 compatibility - || strcmp(scope,"install-path") == 0) + || strcmp (scope, "install-path") == 0) { DBusString temp; - if (!_dbus_get_install_root_as_hash(&temp)) + if (!_dbus_get_install_root_as_hash (&temp)) { - _dbus_string_free(out); + _dbus_string_free (out); return FALSE; } - _dbus_string_append(out,"-"); - _dbus_string_append(out,_dbus_string_get_const_data(&temp)); - _dbus_string_free(&temp); + _dbus_string_append (out, "-"); + _dbus_string_append (out, _dbus_string_get_const_data(&temp)); + _dbus_string_free (&temp); } - else if (strcmp(scope,"*user") == 0) + else if (strcmp (scope, "*user") == 0) { - _dbus_string_append(out,"-"); - if (!_dbus_append_user_from_current_process(out)) + _dbus_string_append (out,"-"); + if (!_dbus_append_user_from_current_process (out)) { - _dbus_string_free(out); + _dbus_string_free (out); return FALSE; } } - else if (strlen(scope) > 0) + else if (strlen (scope) > 0) { - _dbus_string_append(out,"-"); - _dbus_string_append(out,scope); + _dbus_string_append (out, "-"); + _dbus_string_append (out, scope); return TRUE; } return TRUE; @@ -2999,13 +2999,13 @@ _dbus_get_address_string (DBusString *out, const char *basestring, const char *s static dbus_bool_t _dbus_get_shm_name (DBusString *out,const char *scope) { - return _dbus_get_address_string (out,cDBusDaemonAddressInfo,scope); + return _dbus_get_address_string (out, cDBusDaemonAddressInfo, scope); } static dbus_bool_t -_dbus_get_mutex_name (DBusString *out,const char *scope) +_dbus_get_mutex_name (DBusString *out, const char *scope) { - return _dbus_get_address_string (out,cDBusDaemonMutex,scope); + return _dbus_get_address_string (out, cDBusDaemonMutex, scope); } dbus_bool_t @@ -3015,7 +3015,7 @@ _dbus_daemon_is_session_bus_address_published (const char *scope) DBusString mutex_name; _dbus_verbose ("scope:%s\n", scope); - if (!_dbus_get_mutex_name(&mutex_name,scope)) + if (!_dbus_get_mutex_name (&mutex_name, scope)) { _dbus_string_free (&mutex_name); return FALSE; @@ -3073,7 +3073,7 @@ _dbus_daemon_publish_session_bus_address (const char* address, const char *scope _dbus_assert (address); _dbus_verbose ("address:%s scope:%s\n", address, scope); - if (!_dbus_get_mutex_name(&mutex_name,scope)) + if (!_dbus_get_mutex_name (&mutex_name, scope)) { _dbus_string_free (&mutex_name); return FALSE; @@ -3096,7 +3096,7 @@ _dbus_daemon_publish_session_bus_address (const char* address, const char *scope return FALSE; } - if (!_dbus_get_shm_name(&shm_name,scope)) + if (!_dbus_get_shm_name (&shm_name, scope)) { _dbus_string_free (&shm_name); _dbus_global_unlock (lock); @@ -3106,16 +3106,16 @@ _dbus_daemon_publish_session_bus_address (const char* address, const char *scope // create shm len = strlen (address) + 1; - hDBusSharedMem = CreateFileMappingA( INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, + hDBusSharedMem = CreateFileMappingA ( INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, len >> 32, len & 0xffffffffu, - _dbus_string_get_const_data(&shm_name) ); + _dbus_string_get_const_data (&shm_name) ); _dbus_assert (hDBusSharedMem); shared_addr = MapViewOfFile (hDBusSharedMem, FILE_MAP_WRITE, 0, 0, 0); _dbus_assert (shared_addr); - strcpy( shared_addr, address); + strcpy(shared_addr, address); // cleanup UnmapViewOfFile (shared_addr); @@ -3175,7 +3175,7 @@ _dbus_get_autolaunch_shm (DBusString *address, DBusString *shm_name) // read shm for(i=0;i<20;++i) { // we know that dbus-daemon is available, so we wait until shm is available - sharedMem = OpenFileMappingA( FILE_MAP_READ, FALSE, _dbus_string_get_const_data(shm_name)); + sharedMem = OpenFileMappingA (FILE_MAP_READ, FALSE, _dbus_string_get_const_data (shm_name)); if (sharedMem == 0) Sleep (100); if ( sharedMem != 0) @@ -3220,7 +3220,7 @@ _dbus_daemon_already_runs (DBusString *address, DBusString *shm_name, const char lock = _dbus_global_lock (cUniqueDBusInitMutex); // do checks - daemon = CreateMutexA (NULL, FALSE, _dbus_string_get_const_data(&mutex_name)); + daemon = CreateMutexA (NULL, FALSE, _dbus_string_get_const_data (&mutex_name)); if(WaitForSingleObject (daemon, 10) != WAIT_TIMEOUT) { ReleaseMutex (daemon); @@ -3235,7 +3235,7 @@ _dbus_daemon_already_runs (DBusString *address, DBusString *shm_name, const char bRet = _dbus_get_autolaunch_shm (address, shm_name); // cleanup - CloseHandle (daemon); + CloseHandle (daemon); _dbus_global_unlock (lock); _dbus_string_free (&mutex_name); @@ -3244,7 +3244,8 @@ _dbus_daemon_already_runs (DBusString *address, DBusString *shm_name, const char } dbus_bool_t -_dbus_get_autolaunch_address (const char *scope, DBusString *address, +_dbus_get_autolaunch_address (const char *scope, + DBusString *address, DBusError *error) { HANDLE mutex; @@ -3269,7 +3270,7 @@ _dbus_get_autolaunch_address (const char *scope, DBusString *address, if (_dbus_daemon_already_runs (address, &shm_name, scope)) { - _dbus_verbose ( "found running dbus daemon for scope '%s' at %s\n", + _dbus_verbose ("found running dbus daemon for scope '%s' at %s\n", scope ? scope : "", _dbus_string_get_const_data (&shm_name) ); retval = TRUE; goto out; From 1f0331be72d796ba41407b347214ed4393a93f24 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Tue, 14 Dec 2021 15:32:56 +0100 Subject: [PATCH 2/7] _dbus_get_address_string() now expects an initialized DBusString instance as a parameter The mentioned function now expects an initialized DBusString instance as parameter for the return of a string to have a clear responsibility regarding initialization and usage and thus simplify the "out of memory" management. Since the _dbus_get_shm_name() and _dbus_get_mutex_name() functions are affected by the change, the related documentation has been adapted. Signed-off-by: Ralf Habacker --- dbus/dbus-sysdeps-win.c | 46 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index de016c41..35f6f038 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -2957,7 +2957,7 @@ _dbus_get_install_root_as_hash (DBusString *out) static dbus_bool_t _dbus_get_address_string (DBusString *out, const char *basestring, const char *scope) { - _dbus_string_init (out); + _dbus_assert (out != NULL); _dbus_string_append (out, basestring); if (!scope) @@ -2971,7 +2971,6 @@ _dbus_get_address_string (DBusString *out, const char *basestring, const char *s DBusString temp; if (!_dbus_get_install_root_as_hash (&temp)) { - _dbus_string_free (out); return FALSE; } _dbus_string_append (out, "-"); @@ -2983,7 +2982,6 @@ _dbus_get_address_string (DBusString *out, const char *basestring, const char *s _dbus_string_append (out,"-"); if (!_dbus_append_user_from_current_process (out)) { - _dbus_string_free (out); return FALSE; } } @@ -2996,12 +2994,29 @@ _dbus_get_address_string (DBusString *out, const char *basestring, const char *s return TRUE; } +/** + * Return name of shared memory segment constructed from the autolaunch scope \p scope + * + * See @ref _dbus_get_address_string for further usage information. + * + * @param out initialized DBusString instance to return shared memory segment name + * @returns #FALSE on OOM, #TRUE if not OOM + */ static dbus_bool_t _dbus_get_shm_name (DBusString *out,const char *scope) { return _dbus_get_address_string (out, cDBusDaemonAddressInfo, scope); } +/** + * Return mutex name for scope \p scope in \p out + * + * See @ref _dbus_get_address_string for further usage information. + * + * @param out initialized DBusString instance to return mutex name + * @param scope scope for the requested mutex name + * @returns #FALSE on OOM, #TRUE if not OOM + */ static dbus_bool_t _dbus_get_mutex_name (DBusString *out, const char *scope) { @@ -3014,6 +3029,9 @@ _dbus_daemon_is_session_bus_address_published (const char *scope) HANDLE lock; DBusString mutex_name; + if (!_dbus_string_init (&mutex_name)) + return FALSE; + _dbus_verbose ("scope:%s\n", scope); if (!_dbus_get_mutex_name (&mutex_name, scope)) { @@ -3072,6 +3090,9 @@ _dbus_daemon_publish_session_bus_address (const char* address, const char *scope _dbus_assert (address); + if (!_dbus_string_init (&mutex_name)) + return FALSE; + _dbus_verbose ("address:%s scope:%s\n", address, scope); if (!_dbus_get_mutex_name (&mutex_name, scope)) { @@ -3096,6 +3117,12 @@ _dbus_daemon_publish_session_bus_address (const char* address, const char *scope return FALSE; } + if (!_dbus_string_init (&shm_name)) + { + _dbus_global_unlock (lock); + return FALSE; + } + if (!_dbus_get_shm_name (&shm_name, scope)) { _dbus_string_free (&shm_name); @@ -3210,6 +3237,9 @@ _dbus_daemon_already_runs (DBusString *address, DBusString *shm_name, const char DBusString mutex_name; dbus_bool_t bRet = TRUE; + if (!_dbus_string_init (&mutex_name)) + return FALSE; + if (!_dbus_get_mutex_name (&mutex_name,scope)) { _dbus_string_free (&mutex_name); @@ -3260,10 +3290,16 @@ _dbus_get_autolaunch_address (const char *scope, _DBUS_ASSERT_ERROR_IS_CLEAR (error); - if (!_dbus_get_shm_name (&shm_name,scope)) + if (!_dbus_string_init (&shm_name)) + { + _DBUS_SET_OOM(error); + return FALSE; + } + + if (!_dbus_get_shm_name (&shm_name, scope)) { dbus_set_error_const (error, DBUS_ERROR_FAILED, "could not determine shm name"); - return FALSE; + goto out; } mutex = _dbus_global_lock (cDBusAutolaunchMutex); From dbc8f2a81862faf7178f9d10ea5e0c75e921937b Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Tue, 14 Dec 2021 15:16:33 +0100 Subject: [PATCH 3/7] _dbus_get_install_root_as_hash() now expects an initialized DBusString instance as a parameter Since the _dbus_get_address_string() function is affected by the change, the code calling the mentioned function been adapted. Signed-off-by: Ralf Habacker --- dbus/dbus-sysdeps-win.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 35f6f038..9f617695 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -2934,10 +2934,18 @@ static const char *cDBusDaemonMutex = "DBusDaemonMutex"; // named shm for dbus adress info (per user) static const char *cDBusDaemonAddressInfo = "DBusDaemonAddressInfo"; +/** + * Return the hash of the installation root directory, which can be + * used to construct a per-installation-root scope for autolaunching + * + * @param out initialized DBusString instance to return hash string + * @returns #FALSE on OOM, #TRUE if not OOM + */ static dbus_bool_t _dbus_get_install_root_as_hash (DBusString *out) { DBusString install_path; + _dbus_assert (out != NULL); _dbus_string_init (&install_path); @@ -2945,7 +2953,6 @@ _dbus_get_install_root_as_hash (DBusString *out) _dbus_string_get_length (&install_path) == 0) return FALSE; - _dbus_string_init (out); _dbus_string_tolower_ascii (&install_path, 0, _dbus_string_get_length (&install_path)); if (!_dbus_sha_compute (&install_path, out)) @@ -2969,13 +2976,21 @@ _dbus_get_address_string (DBusString *out, const char *basestring, const char *s || strcmp (scope, "install-path") == 0) { DBusString temp; + dbus_bool_t retval = FALSE; + + if (!_dbus_string_init (&temp)) + return FALSE; + if (!_dbus_get_install_root_as_hash (&temp)) - { - return FALSE; - } - _dbus_string_append (out, "-"); - _dbus_string_append (out, _dbus_string_get_const_data(&temp)); + goto out; + + if (!_dbus_string_append_printf (out, "-%s", dbus_string_get_const_data (&temp))) + goto out; + + retval = TRUE; +out: _dbus_string_free (&temp); + return retval; } else if (strcmp (scope, "*user") == 0) { From d9e404c03a199744e1fd905fa7f4b4c13a1e8319 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Tue, 14 Dec 2021 15:23:27 +0100 Subject: [PATCH 4/7] Fix "out of memory" handling in _dbus_get_address_string() To avoid partial strings, appending to the returned string is only done if fully successful. Signed-off-by: Ralf Habacker --- dbus/dbus-sysdeps-win.c | 52 ++++++++++++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 9f617695..53c7380f 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -2961,15 +2961,29 @@ _dbus_get_install_root_as_hash (DBusString *out) return TRUE; } +/** + * Build a name from \p basestring and \p scope, and append it to \p out + * + * The name will be suitable for naming Windows objects such as mutexes + * and shared memory segments that need to be unique for each distinct + * \p scope, but shared between clients with the same \p scope. + * + * If \p scope has one of the special values recognised in autolaunch: + * addresses on Windows, substitute a unique string based on the scope + * (the username or the hash of the installation path) instead of the + * literal scope itself. + * + * @param out initialized DBusString instance to return bus address + * @returns #FALSE on OOM, #TRUE if not OOM + */ static dbus_bool_t _dbus_get_address_string (DBusString *out, const char *basestring, const char *scope) { _dbus_assert (out != NULL); - _dbus_string_append (out, basestring); - if (!scope) + if (!scope || strlen (scope) == 0) { - return TRUE; + return _dbus_string_append (out, basestring); } else if (strcmp (scope, "*install-path") == 0 // for 1.3 compatibility @@ -2984,7 +2998,14 @@ _dbus_get_address_string (DBusString *out, const char *basestring, const char *s if (!_dbus_get_install_root_as_hash (&temp)) goto out; - if (!_dbus_string_append_printf (out, "-%s", dbus_string_get_const_data (&temp))) + if (_dbus_string_get_length (&temp) == 0) + { + _dbus_string_set_length (out, 0); + retval = TRUE; + goto out; + } + + if (!_dbus_string_append_printf (out, "%s-%s", basestring, _dbus_string_get_const_data (&temp))) goto out; retval = TRUE; @@ -2994,19 +3015,22 @@ out: } else if (strcmp (scope, "*user") == 0) { - _dbus_string_append (out,"-"); - if (!_dbus_append_user_from_current_process (out)) - { - return FALSE; - } + char *sid = NULL; + dbus_bool_t retval; + + if (!_dbus_getsid (&sid, _dbus_getpid())) + return FALSE; + + retval = _dbus_string_append_printf (out, "%s-%s", basestring, sid); + + LocalFree(sid); + + return retval; } - else if (strlen (scope) > 0) + else /* strlen(scope) > 0 */ { - _dbus_string_append (out, "-"); - _dbus_string_append (out, scope); - return TRUE; + return _dbus_string_append_printf (out, "%s-%s", basestring, scope); } - return TRUE; } /** From 1bbc135234731ce1b6ac65dd1c6907dbb01c8833 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Tue, 14 Dec 2021 15:24:08 +0100 Subject: [PATCH 5/7] Fix "out of memory" handling in _dbus_get_install_root_as_hash() Signed-off-by: Ralf Habacker --- dbus/dbus-sysdeps-win.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index 53c7380f..deb275a8 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -2945,20 +2945,26 @@ static dbus_bool_t _dbus_get_install_root_as_hash (DBusString *out) { DBusString install_path; + dbus_bool_t retval = FALSE; _dbus_assert (out != NULL); - _dbus_string_init (&install_path); + if (!_dbus_string_init (&install_path)) + return FALSE; if (!_dbus_get_install_root (&install_path) || _dbus_string_get_length (&install_path) == 0) - return FALSE; + goto out; _dbus_string_tolower_ascii (&install_path, 0, _dbus_string_get_length (&install_path)); if (!_dbus_sha_compute (&install_path, out)) - return FALSE; + goto out; - return TRUE; + retval = TRUE; + +out: + _dbus_string_free (&install_path); + return retval; } /** From 9e350224366db649cd374fafa723d168e92ae566 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Wed, 15 Dec 2021 09:31:15 +0100 Subject: [PATCH 6/7] Cleanup zero string length case condition in Windows helper functions This cleanup has been processed in _dbus_daemon_publish_session_bus_address() _dbus_get_install_root_as_hash() and _dbus_get_address_string(). The zero length condition has been catched in each function calling the mentioned functions. Signed-off-by: Ralf Habacker --- dbus/dbus-sysdeps-win.c | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index deb275a8..cfa846eb 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -2938,6 +2938,9 @@ static const char *cDBusDaemonAddressInfo = "DBusDaemonAddressInfo"; * Return the hash of the installation root directory, which can be * used to construct a per-installation-root scope for autolaunching * + * If the installation root directory could not be + * determined, the returned length is set to zero. + * * @param out initialized DBusString instance to return hash string * @returns #FALSE on OOM, #TRUE if not OOM */ @@ -2951,10 +2954,17 @@ _dbus_get_install_root_as_hash (DBusString *out) if (!_dbus_string_init (&install_path)) return FALSE; - if (!_dbus_get_install_root (&install_path) || - _dbus_string_get_length (&install_path) == 0) + if (!_dbus_get_install_root (&install_path)) goto out; + /* the install path can't be determined */ + if (_dbus_string_get_length (&install_path) == 0) + { + _dbus_string_set_length (out, 0); + retval = TRUE; + goto out; + } + _dbus_string_tolower_ascii (&install_path, 0, _dbus_string_get_length (&install_path)); if (!_dbus_sha_compute (&install_path, out)) @@ -2979,6 +2989,9 @@ out: * (the username or the hash of the installation path) instead of the * literal scope itself. * + * With the '*install-path' \p scope the returned length can be zero, + * indicating that the name could not be determined. + * * @param out initialized DBusString instance to return bus address * @returns #FALSE on OOM, #TRUE if not OOM */ @@ -3078,7 +3091,9 @@ _dbus_daemon_is_session_bus_address_published (const char *scope) return FALSE; _dbus_verbose ("scope:%s\n", scope); - if (!_dbus_get_mutex_name (&mutex_name, scope)) + if (!_dbus_get_mutex_name (&mutex_name, scope) || + /* not determinable */ + _dbus_string_get_length (&mutex_name) == 0) { _dbus_string_free (&mutex_name); return FALSE; @@ -3139,7 +3154,9 @@ _dbus_daemon_publish_session_bus_address (const char* address, const char *scope return FALSE; _dbus_verbose ("address:%s scope:%s\n", address, scope); - if (!_dbus_get_mutex_name (&mutex_name, scope)) + if (!_dbus_get_mutex_name (&mutex_name, scope) || + /* not determinable */ + _dbus_string_get_length (&mutex_name) == 0) { _dbus_string_free (&mutex_name); return FALSE; @@ -3168,7 +3185,9 @@ _dbus_daemon_publish_session_bus_address (const char* address, const char *scope return FALSE; } - if (!_dbus_get_shm_name (&shm_name, scope)) + if (!_dbus_get_shm_name (&shm_name, scope) || + /* not determinable */ + _dbus_string_get_length (&shm_name) == 0) { _dbus_string_free (&shm_name); _dbus_global_unlock (lock); @@ -3285,7 +3304,9 @@ _dbus_daemon_already_runs (DBusString *address, DBusString *shm_name, const char if (!_dbus_string_init (&mutex_name)) return FALSE; - if (!_dbus_get_mutex_name (&mutex_name,scope)) + if (!_dbus_get_mutex_name (&mutex_name,scope) || + /* not determinable */ + _dbus_string_get_length (&mutex_name) == 0) { _dbus_string_free (&mutex_name); return FALSE; @@ -3341,7 +3362,9 @@ _dbus_get_autolaunch_address (const char *scope, return FALSE; } - if (!_dbus_get_shm_name (&shm_name, scope)) + if (!_dbus_get_shm_name (&shm_name, scope) || + /* not determinable */ + _dbus_string_get_length (&shm_name) == 0) { dbus_set_error_const (error, DBUS_ERROR_FAILED, "could not determine shm name"); goto out; From 8a6a8a794fd65209452f52142278b6852a9fc1fe Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Thu, 16 Dec 2021 10:01:35 +0100 Subject: [PATCH 7/7] In _dbus_get_autolaunch_address() avoid uninitialized mutex Signed-off-by: Ralf Habacker --- dbus/dbus-sysdeps-win.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dbus/dbus-sysdeps-win.c b/dbus/dbus-sysdeps-win.c index cfa846eb..9d9552d0 100644 --- a/dbus/dbus-sysdeps-win.c +++ b/dbus/dbus-sysdeps-win.c @@ -3344,7 +3344,7 @@ _dbus_get_autolaunch_address (const char *scope, DBusString *address, DBusError *error) { - HANDLE mutex; + HANDLE mutex = NULL; STARTUPINFOA si; PROCESS_INFORMATION pi; dbus_bool_t retval = FALSE; @@ -3454,7 +3454,8 @@ _dbus_get_autolaunch_address (const char *scope, out: _DBUS_ASSERT_ERROR_XOR_BOOL (error, retval); - _dbus_global_unlock (mutex); + if (mutex != NULL) + _dbus_global_unlock (mutex); _dbus_string_free (&shm_name); _dbus_string_free (&dbus_args);