panel segfaulting

I have tracked down the segfault I've been getting from panel to the
function gnome_dirrelative_file in gnome-util.c in libgnome.  According to
the ChangeLog from Bonsai, this file is up to date (mine is dated Jan 13).

I was assuming that I did not have to set the GNOMEDIR environment
variable in order to keep the panel from segfaulting.  If this is a bad
assumption, please read no further...  :)  panel runs fine if I export
GNOMEDIR=/home/edcarter before starting panel.

Here it is, with comments added by me to indicate what happens that causes
this function to return NULL which soon leads to a segfault:

static char *
gnome_dirrelative_file (const char *base, const char *sub, const char
*filename, int unconditional)
/* the offending call passes *base == "/home/edcarter/share", *sub ==
"share", *filename == "gtkrc", and unconditional == 1 */

        static char *gnomedir = NULL;
	char *f = NULL, *t = NULL, *u = NULL, *v = NULL;
	char *retval = NULL;
	/* First try the env GNOMEDIR relative path */
	if (!gnomedir)
		gnomedir = getenv ("GNOMEDIR");
/* if I don't set GNOMEDIR, gnomedir still == NULL */

	if (gnomedir) {
		t = g_concat_dir_and_file (gnomedir, sub);
		u = g_strconcat (t, "/", filename, NULL);
		g_free (t); t = NULL;
		if (g_file_exists (u)) {
			retval = u; u = NULL; goto out;

		t = g_concat_dir_and_file (gnome_util_user_home (), sub);
		v = g_strconcat (t, "/", filename, NULL);
		g_free (t); t = NULL;

		if (g_file_exists (v)){
			retval = v; v = NULL; goto out;

		if (unconditional) {
			retval = u; u = NULL; goto out;

/* above part doesn't matter since gnomedir == NULL */

	g_free(t); t = NULL;
		t = g_concat_dir_and_file (gnomedir, sub);
		t = g_concat_dir_and_file (gnome_util_user_home (), sub);

/* right here we have some change: *t == "/home/edcarter/share" */

	if(t && strcmp(base, t)) {
		/* Then try the hardcoded path */
		f = g_concat_dir_and_file (base, filename);
		if (g_file_exists (f) || unconditional) {
			retval = f; f = NULL; goto out;

/* one of the conditions is met (t != NULL), but the strcmp call returns
0, so the above part here doesn't matter either...  why exactly does
*base need to be different from *t? */

	/* Finally, attempt to find it in the current directory */
	g_free (f);
	f = g_concat_dir_and_file (".", filename);

/* here *f == "./gtkrc" but that's obvious.  btw, I don't have a ./gtkrc
when I run panel */

	if (g_file_exists (f)) {
		retval = f; f = NULL; goto out;

/* nothing's changed here since I don't have ./gtkrc */

	g_free(f); g_free(t); g_free(v); g_free(u);

/* and there we have it: retval is still NULL which will soon lead to a
segfault.  does anyone else know what exactly went wrong? */

	return retval;

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]