[PATCH] Remove an xfree from add_path

Tom Tromey tom@tromey.com
Wed Dec 8 04:53:45 GMT 2021


Simon> The test gdb.base/source-dir.exp started to fail here following this patch.
Simon> Let me know if you can't reproduce.

Ugh, sorry.  I think I must have "harmlessly" tweaked the patch after
testing.

I'm checking in this fix.  I made a baseline by running make check
before the earlier patch, then applied this and retested.

Tom

commit 5fdb09a2fd55d4bcf227099b93c1906588399f02
Author: Tom Tromey <tom@tromey.com>
Date:   Tue Dec 7 21:51:03 2021 -0700

    Fix bug in source.c change
    
    My earlier change to source.c ("Remove an xfree from add_path")
    introduced a regression.  This patch fixes the problem.

diff --git a/gdb/source.c b/gdb/source.c
index d91389e28b7..f28c30628e6 100644
--- a/gdb/source.c
+++ b/gdb/source.c
@@ -660,8 +660,8 @@ add_path (const char *dirname, char **which_path, int parse_separators)
 	   more.  */
 	if (prefix)
 	  {
-	    std::string temp (old, prefix);
-	    *which_path = concat (temp.c_str (), tinybuf, name, &old[prefix],
+	    std::string temp = std::string (old, prefix) + tinybuf + name;
+	    *which_path = concat (temp.c_str (), &old[prefix],
 				  (char *) nullptr);
 	    prefix = temp.length ();
 	  }


More information about the Gdb-patches mailing list