git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mailmap: fix check for freeing memory
@ 2013-08-20 13:22 Stefan Beller
  2013-08-20 13:40 ` Thomas Rast
  0 siblings, 1 reply; 12+ messages in thread
From: Stefan Beller @ 2013-08-20 13:22 UTC (permalink / raw)
  To: git, peff, gitster; +Cc: Stefan Beller

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

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2013-08-20 17:45 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-20 13:22 [PATCH] mailmap: fix check for freeing memory Stefan Beller
2013-08-20 13:40 ` Thomas Rast
2013-08-20 13:52   ` Jeff King
2013-08-20 14:17   ` Stefan Beller
2013-08-20 14:18     ` [PATCH] mailmap: remove redundant " Stefan Beller
2013-08-20 14:28       ` Jeff King
2013-08-20 14:23     ` [PATCH] mailmap: fix " Thomas Rast
2013-08-20 14:38       ` Stefan Beller
2013-08-20 16:12         ` Jeff King
2013-08-20 17:18           ` Junio C Hamano
2013-08-20 17:45             ` Jeff King
2013-08-20 14:27     ` Jeff King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).