]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Don't read ./.valgrindrc if CWD==HOME.
authorNicholas Nethercote <njn@valgrind.org>
Mon, 26 Mar 2007 22:10:53 +0000 (22:10 +0000)
committerNicholas Nethercote <njn@valgrind.org>
Mon, 26 Mar 2007 22:10:53 +0000 (22:10 +0000)
Merged from trunk (r6660).  Also required r6380.

git-svn-id: svn://svn.valgrind.org/valgrind/branches/VALGRIND_3_2_BRANCH@6666

coregrind/m_commandline.c

index dd809a83df1ca75c7c21a8668cf145a83085eab0..6a8c101eb6973b3ae0565e10dc45cd0ee4c8395f 100644 (file)
@@ -207,9 +207,19 @@ void VG_(split_up_argv)( Int argc, HChar** argv )
       // read_dot_valgrindrc() allocates the return value with
       // VG_(malloc)().  We do not free f1_clo and f2_clo as they get
       // put into VG_(args_for_valgrind) and so must persist.
-      HChar* f1_clo  = read_dot_valgrindrc( VG_(getenv)("HOME") );
+      HChar* home    = VG_(getenv)("HOME");
+      HChar* f1_clo  = home ? read_dot_valgrindrc( home ) : NULL;
       HChar* env_clo = VG_(strdup)( VG_(getenv)(VALGRIND_OPTS) );
-      HChar* f2_clo  = read_dot_valgrindrc(".");
+      HChar* f2_clo  = NULL;
+
+      // Don't read ./.valgrindrc if "." is the same as "$HOME", else its
+      // contents will be applied twice. (bug #142488)
+      if (home) {
+         HChar cwd[VKI_PATH_MAX+1];
+         Bool  cwd_ok = VG_(getcwd)(cwd, VKI_PATH_MAX);
+         f2_clo = ( (cwd_ok && VG_STREQ(home, cwd))
+                       ? NULL : read_dot_valgrindrc(".") );
+      }
 
       if (f1_clo)  add_args_from_string( f1_clo );
       if (env_clo) add_args_from_string( env_clo );