Created attachment 338340 [details] proposal patch Description of problem: Look at the following simple code: ---------------------------------------------------- #include <stdio.h> #include <string.h> int main(int argc, char **argv){ extern char **environ; int i = 0; while (environ[i]){ if (environ[i] == strstr(environ[i], "DISPLAY")) fprintf (stderr, "argv[%i] is \"%s\"\n", i, environ[i]); i++; } return 0; } ----------------------------------------------------- When I - login to GNOME session, launch xterm - execute the code above on the xterm the code above simply shows: ----------------------------------------------------- argv[45] is "DISPLAY=:0.0" ----------------------------------------------------- for example. However when I - login to GNOME session - right click on GNOME panel, select "Add to panel" - select "custom application launcher" and select the binary generated from the code above - click the icon newly added on the panel - watch ~/.xsession-errors then the following appears: ----------------------------------------------------- argv[34] is "DISPLAY=:0.0" argv[45] is "DISPLAY=:0.0" ----------------------------------------------------- This shows char **environ has two "DISPLAY" item?? Version-Release number of selected component (if applicable): glib2-2.19.10-2.fc11 glib2-2.20.0-1.fc11 How reproducible: 100% Steps to Reproduce: 1. See above 2. 3. Actual results: This causes that pcmanfm (which I maintain) cannot launch any commands when pcmanfm is launched from GNOME menu (sourceforge bug id 2313286) Expected results: "DISPLAY" item should appear only once Additional info: The attached patch seems to work. Actually on static gboolean is_env (const char *a, const char *b) in gio/gdesktopappinfo.c: ------------------------------------------------------ 828 static gboolean 829 is_env (const char *a, 830 const char *b) 831 { 832 while (*a == *b) 833 { 834 if (*a == 0 || *b == 0) 835 return FALSE; 836 837 if (*a == '=') 838 return TRUE; 839 840 a++; 841 b++; 842 } 843 844 return FALSE; 845 } -------------------------------------------------------- suppose a="DISPLAY=:0.0" and b="DISPLAY" I guess this should return TRUE but actually this returns FALSE - because after a,b both points to 'Y', at lines 840-841 now *a='=' while *b=0, then while (*a == *b) at 832 fails.
(In reply to comment #0) > fprintf (stderr, "argv[%i] is \"%s\"\n", i, environ[i]); This should be fprintf (stderr, "environ[%i is ....... but the result is the same.
This is not a bug, it is just the way environ works