git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Fix make_absolute_path() for parameters without a slash

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Mar 2, 2008, 07:17 UTC
Message-ID
<alpine.LSU.1.00.0803020717060.22527@racer.site>

When passing "xyz" to make_absolute_path(), make_absolute_path() erroneously tried to chdir("xyz"), and then append "/xyz". Instead, skip the chdir() completely when no slash was found.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
	I should add a test, but I am simply too tired now.  Will do so 
	tomorrow.
 path.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/path.c b/path.c
index 4260952..bf3e469 100644
--- a/path.c
+++ b/path.c
@@ -311,8 +311,10 @@ const char *make_absolute_path(const char *path)
 			if (last_slash) {
 				*last_slash = '\0';
 				last_elem = xstrdup(last_slash + 1);
-			} else
+			} else {
+				*buf = '\0';
 				last_elem = xstrdup(buf);
+			}
 		}
 
 		if (*buf) {
-- 
1.5.4.3.446.gbe8932
Next: Johannes Schindelin
Message 1 of 3 in “Fix make_absolute_path() for parameters without a slash”
  1. Fix make_absolute_path() for parameters without a slashJohannes Schindelin, Mar 2, 2008
  2. Johannes SchindelinMar 2, 2008
  3. Fix make_absolute_path() for parameters without a slashJohannes Schindelin, Mar 2, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.