From 5d9cfa29d27156cc9a00c75eaa31b831107ed0b9 Mon Sep 17 00:00:00 2001 From: Stefan Beller Date: Sun, 14 Jul 2013 23:35:46 +0200 Subject: [PATCH 1/3] daemon.c:handle: Remove unneeded check for null pointer. addr doesn't need to be checked at that line as it it already accessed 7 lines before in the if (addr->sa_family). Signed-off-by: Stefan Beller Reviewed-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- daemon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daemon.c b/daemon.c index df8c0ab058..80df5cb54e 100644 --- a/daemon.c +++ b/daemon.c @@ -760,7 +760,7 @@ static void handle(int incoming, struct sockaddr *addr, socklen_t addrlen) snprintf(portbuf, sizeof(portbuf), "REMOTE_PORT=%d", ntohs(sin_addr->sin_port)); #ifndef NO_IPV6 - } else if (addr && addr->sa_family == AF_INET6) { + } else if (addr->sa_family == AF_INET6) { struct sockaddr_in6 *sin6_addr = (void *) addr; char *buf = addrbuf + 12; From 70a0cc9e5c62f7b8ce0acc693e10a9e080f187ef Mon Sep 17 00:00:00 2001 From: Stefan Beller Date: Sun, 14 Jul 2013 23:35:47 +0200 Subject: [PATCH 2/3] commit: Fix a memory leak in determine_author_info The date variable is assigned new memory via xmemdupz and 2 lines later it is assigned new memory again via xmalloc, but the first assignment is never freed nor used. Signed-off-by: Stefan Beller Reviewed-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- builtin/commit.c | 1 - 1 file changed, 1 deletion(-) diff --git a/builtin/commit.c b/builtin/commit.c index d21d07a1a8..0575ad8ecd 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -526,7 +526,6 @@ static void determine_author_info(struct strbuf *author_ident) (lb - strlen(" ") - (a + strlen("\nauthor ")))); email = xmemdupz(lb + strlen("<"), rb - (lb + strlen("<"))); - date = xmemdupz(rb + strlen("> "), eol - (rb + strlen("> "))); len = eol - (rb + strlen("> ")); date = xmalloc(len + 2); *date = '@'; From d3c9cf32ca3b088fda54e7be311860f1f06fb11e Mon Sep 17 00:00:00 2001 From: Stefan Beller Date: Sun, 14 Jul 2013 23:35:49 +0200 Subject: [PATCH 3/3] diff.c: Do not initialize a variable, which gets reassigned anyway. Signed-off-by: Stefan Beller Reviewed-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- diff.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/diff.c b/diff.c index 649ec86b87..2747e6f72c 100644 --- a/diff.c +++ b/diff.c @@ -1683,9 +1683,7 @@ static void show_stats(struct diffstat_t *data, struct diff_options *options) del = deleted; if (graph_width <= max_change) { - int total = add + del; - - total = scale_linear(add + del, graph_width, max_change); + int total = scale_linear(add + del, graph_width, max_change); if (total < 2 && add && del) /* width >= 2 due to the sanity check */ total = 2;