[PATCH] fix some resource leaks discovered by cppcheck

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 builtin/fmt-merge-msg.c |    2 ++
 builtin/rerere.c        |    1 +
 transport.c             |    1 +
 3 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c
index 9d52400..7c9ee96 100644
--- a/builtin/fmt-merge-msg.c
+++ b/builtin/fmt-merge-msg.c
@@ -373,6 +373,8 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
 
 	if (strbuf_read(&input, fileno(in), 0) < 0)
 		die_errno("could not read input file");
+	if(in != stdin)
+		fclose(in);
 	ret = fmt_merge_msg(merge_summary, &input, &output);
 	if (ret)
 		return ret;
diff --git a/builtin/rerere.c b/builtin/rerere.c
index 34f9ace..de76d48 100644
--- a/builtin/rerere.c
+++ b/builtin/rerere.c
@@ -64,6 +64,7 @@ static void garbage_collect(struct string_list *rr)
 	for (i = 0; i < to_remove.nr; i++)
 		unlink_rr_item(to_remove.items[i].string);
 	string_list_clear(&to_remove, 0);
+	closedir(dir);
 }
 
 static int outf(void *dummy, mmbuffer_t *ptr, int nbuf)
diff --git a/transport.c b/transport.c
index 8ce3936..1c61145 100644
--- a/transport.c
+++ b/transport.c
@@ -134,6 +134,7 @@ static void insert_packed_refs(const char *packed_refs, struct ref **list)
 			list = &(*list)->next;
 		}
 	}
+	fclose(f);
 }
 
 static void set_upstreams(struct transport *transport, struct ref *refs,
-- 
1.7.0.3.313.g87b3c.dirty

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]