Index: /trunk/docs/Changelog
===================================================================
--- /trunk/docs/Changelog	(revision 512)
+++ /trunk/docs/Changelog	(revision 513)
@@ -1,3 +1,5 @@
 4.1.6:
+	* fix minor bug in error message (tf_trust_errfile needs copy to
+	keep relevant value).
 	* fix SH_DEADFILE (too big, some architectures have nlink_t
 	as uint16, e.g. FreeBSD).
Index: /trunk/src/sh_unix.c
===================================================================
--- /trunk/src/sh_unix.c	(revision 512)
+++ /trunk/src/sh_unix.c	(revision 513)
@@ -1210,4 +1210,6 @@
   int    level;
   uid_t  ff_euid = (uid_t) -1;
+  uid_t  baduid;
+  gid_t  badgid;
 
   SL_ENTER(_("tf_trust_check"));
@@ -1256,9 +1258,12 @@
 	level = SH_ERR_ERR;
 
-      tmp  = sh_util_safe_name (file);
-      p    = sl_trust_errfile();
+      tmp    = sh_util_safe_name (file);
+      p      = sh_util_strdup(sl_trust_errfile());
+      baduid = sl_trust_baduid();
+      badgid = sl_trust_badgid();
+      
       if (p && *p != '\0')
 	{
-	  tmp2  = sh_util_safe_name (sl_trust_errfile());
+	  tmp2  = sh_util_safe_name (p);
 	  sh_error_handle(level, FIL__, __LINE__, status, MSG_E_TRUST2,
 			  sl_error_string(status), tmp, tmp2);
@@ -1270,5 +1275,4 @@
 			  sl_error_string(status), tmp);
 	}
-      SH_FREE(tmp);
 
       if (status == SL_EBADUID   || status == SL_EBADGID || 
@@ -1282,41 +1286,35 @@
 	    break;
 	  case SL_ETRUNC:
-	    tmp  = sh_util_safe_name (file);
 	    dlog(1, FIL__, __LINE__, 
 		 _("A filename truncation occured in the trustfile function.\nProbably the normalized filename for %s\nis too long. This may be due e.g. to deep or circular softlinks.\n"), 
 		 tmp);
-	    SH_FREE(tmp);
 	    break;
 	  case SL_EBADOTH:
-	    tmp  = sh_util_safe_name (file);
-	    p    = sl_trust_errfile();
 	    dlog(1, FIL__, __LINE__, 
 		 _("The path element: %s\nin the filename: %s is world writeable.\n"),
-		 p, tmp);
-	    SH_FREE(tmp);
+		 (p) ? p : _("(null)"), tmp);
 	    break;
 	  case SL_EBADUID:
-	    tmp  = sh_util_safe_name (file);
-	    p    = sl_trust_errfile();
 	    dlog(1, FIL__, __LINE__, 
 		 _("The owner (UID = %ld) of the path element: %s\nin the filename: %s\nis not in the list of trusted users.\nTo fix the problem, you can:\n - run ./configure again with the option --with-trusted=0,...,UID\n   where UID is the UID of the untrusted user, or\n - use the option TrustedUser=UID in the configuration file.\n"),
-		 (UID_CAST)sl_trust_baduid(), p, tmp);
-	    SH_FREE(tmp);
+		 (UID_CAST)baduid, (p) ? p : _("(null)"), tmp);
 	    break;
 	  case SL_EBADGID:
-	    tmp  = sh_util_safe_name (file);
-	    p    = sl_trust_errfile();
 	    dlog(1, FIL__, __LINE__, 
 		 _("The path element: %s\nin the filename: %s\nis group writeable (GID = %ld), and at least one of the group\nmembers (UID = %ld) is not in the list of trusted users.\nTo fix the problem, you can:\n - run ./configure again with the option --with-trusted=0,...,UID\n   where UID is the UID of the untrusted user, or\n - use the option TrustedUser=UID in the configuration file.\n"),
-		 p, tmp, (UID_CAST)sl_trust_badgid(), 
-		 (UID_CAST)sl_trust_baduid());
-	    SH_FREE(tmp);
+		 (p) ? p : _("(null)"), tmp, (UID_CAST)badgid, 
+		 (UID_CAST)baduid);
 	    break;
 	  default:
 	    break;
 	  }
-	    
+	  SH_FREE(tmp);
+	  if (p) SH_FREE(p);
 	  SL_RETURN((-1), _("tf_trust_check"));
 	}
+      else {
+	SH_FREE(tmp);
+	if (p) SH_FREE(p);
+      }
     }
 
