[gnome-session] gsm-util: avoid overwriting a env variable with itself
- From: Ray Strode <halfline src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-session] gsm-util: avoid overwriting a env variable with itself
- Date: Sat, 7 Nov 2015 02:50:48 +0000 (UTC)
commit 771dc6c12c051048fdb386703813081954e56492
Author: Giovanni Campagna <gcampagn cs stanford edu>
Date: Wed Nov 4 09:36:44 2015 -0800
gsm-util: avoid overwriting a env variable with itself
This avoids a potentially thread-safety issue in our use of
gsm_util_setenv() to push locale variables to DBus.
https://bugzilla.gnome.org/show_bug.cgi?id=756324
gnome-session/gsm-util.c | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/gnome-session/gsm-util.c b/gnome-session/gsm-util.c
index b7d2cda..e7ceec4 100644
--- a/gnome-session/gsm-util.c
+++ b/gnome-session/gsm-util.c
@@ -497,10 +497,16 @@ gsm_util_setenv (const char *variable,
{
GError *bus_error;
- if (!value)
- g_unsetenv (variable);
- else
- g_setenv (variable, value, TRUE);
+ /* Note: we're intentionally comparing pointers here:
+ The goal is to avoid an un-threadsafe env variable update
+ when this API is used in maybe_push_env_var() in main.c
+ */
+ if (g_getenv (variable) != value) {
+ if (!value)
+ g_unsetenv (variable);
+ else
+ g_setenv (variable, value, TRUE);
+ }
bus_error = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]