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

git.c: two fixes, gitsetenv type and off-by-one error.

From
Junio C Hamano <junkio@cox.net>
Date
Dec 4, 2005, 23:03 UTC
Message-ID
<7vhd9oea8e.fsf@assigned-by-dhcp.cox.net>

gitsetenv as implemented in compat/setenv.c takes two const char* and int; match that.

Also fix an incorrect attempt in prepend_to_path() to NUL-terminate the string which stuffed the NUL character at one past the end of allocation, and was not needed to begin with (we copy the old_path string including the NUL which terminates it).

Signed-off-by: Junio C Hamano <junkio@cox.net>
---
 git.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
9a79c5a8b4e280601bcbeeed22e1e4968d06c10e
diff --git a/git.c b/git.c
index 619f25a..0975fc7 100644
--- a/git.c
+++ b/git.c
@@ -14,7 +14,7 @@
 #endif
 
 #ifdef NO_SETENV
-extern int gitsetenv(char *name, char *value, int overwrite);
+extern int gitsetenv(const char *, const char *, int);
 #endif
 
 static const char git_usage[] =
@@ -192,7 +192,6 @@ static void prepend_to_path(const char *
 	path_len = len + strlen(old_path) + 1;
 
 	path = malloc(path_len + 1);
-	path[path_len + 1] = '\0';
 
 	memcpy(path, dir, len);
 	path[len] = ':';
-- 
0.99.9.GIT
Message 1 of 1 in “git.c: two fixes, gitsetenv type and off-by-one error.”
  1. Junio C HamanoDec 4, 2005

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.