From: Stefan Beller <stefanbeller@googlemail.com>
To: git@vger.kernel.org, peff@peff.net, gitster@pobox.com
Cc: Stefan Beller <stefanbeller@googlemail.com>
Subject: [PATCH] mailmap: fix check for freeing memory
Date: Tue, 20 Aug 2013 15:22:38 +0200 [thread overview]
Message-ID: <1377004958-14489-1-git-send-email-stefanbeller@googlemail.com> (raw)
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 reply other threads:[~2013-08-20 13:22 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-20 13:22 Stefan Beller [this message]
2013-08-20 13:40 ` [PATCH] mailmap: fix check for freeing memory 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1377004958-14489-1-git-send-email-stefanbeller@googlemail.com \
--to=stefanbeller@googlemail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).