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

[PATCH] mailmap: fix check for freeing memory

From
Stefan Beller <stefanbeller@googlemail.com>
Date
Aug 20, 2013, 13:22 UTC
Message-ID
<1377004958-14489-1-git-send-email-stefanbeller@googlemail.com>

The condition as it is written in that line was most likely intended to check for the pointer passed to free(), rather than checking for the 'repo_abbrev', which is already checked against being non null at the beginning of the function.

Signed-off-by: Stefan Beller <stefanbeller@googlemail.com>
---
 mailmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mailmap.c b/mailmap.c
index 44614fc..36d2a7a 100644
--- a/mailmap.c
+++ b/mailmap.c
@@ -139,35 +139,35 @@ static char *parse_name_and_email(char *buffer, char **name,
 static void read_mailmap_line(struct string_list *map, char *buffer,
 			      char **repo_abbrev)
 {
 	char *name1 = NULL, *email1 = NULL, *name2 = NULL, *email2 = NULL;
 	if (buffer[0] == '#') {
 		static const char abbrev[] = "# repo-abbrev:";
 		int abblen = sizeof(abbrev) - 1;
 		int len = strlen(buffer);
 
 		if (!repo_abbrev)
 			return;
 
 		if (len && buffer[len - 1] == '\n')
 			buffer[--len] = 0;
 		if (!strncmp(buffer, abbrev, abblen)) {
 			char *cp;
 
-			if (repo_abbrev)
+			if (*repo_abbrev)
 				free(*repo_abbrev);
 			*repo_abbrev = xmalloc(len);
 
 			for (cp = buffer + abblen; isspace(*cp); cp++)
 				; /* nothing */
 			strcpy(*repo_abbrev, cp);
 		}
 		return;
 	}
 	if ((name2 = parse_name_and_email(buffer, &name1, &email1, 0)) != NULL)
 		parse_name_and_email(name2, &name2, &email2, 1);
 
 	if (email1)
 		add_mapping(map, name1, email1, name2, email2);
 }
 
 static int read_mailmap_file(struct string_list *map, const char *filename,
-- 
1.8.4.rc3.1.gc1ebd90
Next: Thomas Rast
Message 1 of 12 in “mailmap: fix check for freeing memory”
  1. mailmap: fix check for freeing memoryStefan Beller, Aug 20, 2013
  2. Thomas RastAug 20, 2013
  3. Jeff KingAug 20, 2013
  4. Stefan BellerAug 20, 2013
  5. mailmap: remove redundant check for freeing memoryStefan Beller, Aug 20, 2013
  6. Jeff KingAug 20, 2013
  7. Thomas RastAug 20, 2013
  8. Stefan BellerAug 20, 2013
  9. Jeff KingAug 20, 2013
  10. Junio C HamanoAug 20, 2013
  11. Jeff KingAug 20, 2013
  12. Jeff KingAug 20, 2013

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.