Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
mktree: plug memory leaks reported by Coverity
author
Johannes Schindelin
<johannes.schindelin@gmx.de>
Thu, 4 May 2017 13:57:28 +0000
(15:57 +0200)
committer
Junio C Hamano
<gitster@pobox.com>
Mon, 8 May 2017 03:18:19 +0000
(12:18 +0900)
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/mktree.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
077a34e
)
diff --git
a/builtin/mktree.c
b/builtin/mktree.c
index de9b40fc63b0a4f76401a111aba806c64ce36ee9..da0fd8cd706659a8784da8112cd1b3acd306375f 100644
(file)
--- a/
builtin/mktree.c
+++ b/
builtin/mktree.c
@@
-72,7
+72,7
@@
static void mktree_line(char *buf, size_t len, int nul_term_line, int allow_miss
unsigned mode;
enum object_type mode_type; /* object type derived from mode */
enum object_type obj_type; /* object type derived from sha */
unsigned mode;
enum object_type mode_type; /* object type derived from mode */
enum object_type obj_type; /* object type derived from sha */
- char *path;
+ char *path
, *to_free = NULL
;
unsigned char sha1[20];
ptr = buf;
unsigned char sha1[20];
ptr = buf;
@@
-102,7
+102,7
@@
static void mktree_line(char *buf, size_t len, int nul_term_line, int allow_miss
struct strbuf p_uq = STRBUF_INIT;
if (unquote_c_style(&p_uq, path, NULL))
die("invalid quoting");
struct strbuf p_uq = STRBUF_INIT;
if (unquote_c_style(&p_uq, path, NULL))
die("invalid quoting");
- path = strbuf_detach(&p_uq, NULL);
+ path =
to_free =
strbuf_detach(&p_uq, NULL);
}
/*
}
/*
@@
-136,6
+136,7
@@
static void mktree_line(char *buf, size_t len, int nul_term_line, int allow_miss
}
append_to_tree(mode, sha1, path);
}
append_to_tree(mode, sha1, path);
+ free(to_free);
}
int cmd_mktree(int ac, const char **av, const char *prefix)
}
int cmd_mktree(int ac, const char **av, const char *prefix)