bus_activation_service_reload_test (const DBusString *test_data_dir)
{
DBusString directory;
+ const char *tmp;
if (!_dbus_string_init (&directory))
return FALSE;
- if (!_dbus_string_append (&directory, _dbus_get_tmpdir()))
+ tmp = _dbus_get_tmpdir ();
+
+ if (tmp == NULL)
+ return FALSE;
+
+ if (!_dbus_string_append (&directory, tmp))
return FALSE;
if (!_dbus_string_append (&directory, "/dbus-reload-test-") ||
_DBUS_LOCK_shutdown_funcs,
_DBUS_LOCK_system_users,
_DBUS_LOCK_message_cache,
- /* index 10-11 */
+ /* index 10-12 */
_DBUS_LOCK_shared_connections,
_DBUS_LOCK_machine_uuid,
+ _DBUS_LOCK_sysdeps,
_DBUS_N_GLOBAL_LOCKS
} DBusGlobalLock;
dbus_bool_t use_subdir)
{
DBusString randomStr;
+ const char *tmp;
_DBUS_ASSERT_ERROR_IS_CLEAR (error);
goto on_error;
}
+ tmp = _dbus_get_tmpdir ();
+
if (!_dbus_string_init (&noncefile->dir)
- || !_dbus_string_append (&noncefile->dir, _dbus_get_tmpdir()))
+ || tmp == NULL
+ || !_dbus_string_append (&noncefile->dir, tmp))
{
dbus_set_error (error, DBUS_ERROR_NO_MEMORY, NULL);
goto on_error;
* Gets the temporary files directory by inspecting the environment variables
* TMPDIR, TMP, and TEMP in that order. If none of those are set "/tmp" is returned
*
- * @returns location of temp directory
+ * @returns location of temp directory, or #NULL if no memory for locking
*/
const char*
_dbus_get_tmpdir(void)
{
+ /* Protected by _DBUS_LOCK_sysdeps */
static const char* tmpdir = NULL;
+ if (!_DBUS_LOCK (sysdeps))
+ return NULL;
+
if (tmpdir == NULL)
{
/* TMPDIR is what glibc uses, then
tmpdir = "/tmp";
}
+ _DBUS_UNLOCK (sysdeps);
+
_dbus_assert(tmpdir != NULL);
return tmpdir;
* Gets the temporary files directory by inspecting the environment variables
* TMPDIR, TMP, and TEMP in that order. If none of those are set "/tmp" is returned
*
- * @returns location of temp directory
+ * @returns location of temp directory, or #NULL if no memory for locking
*/
const char*
_dbus_get_tmpdir(void)
{
+ /* Protected by _DBUS_LOCK_sysdeps */
static const char* tmpdir = NULL;
static char buf[1000];
+ if (!_DBUS_LOCK (sysdeps))
+ return NULL;
+
if (tmpdir == NULL)
{
char *last_slash;
tmpdir = buf;
}
+ _DBUS_UNLOCK (sysdeps);
+
_dbus_assert(tmpdir != NULL);
return tmpdir;