Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew DeVore <matvore@google.com>2018-10-06 00:31:26 +0300
committerJunio C Hamano <gitster@pobox.com>2018-10-07 02:55:00 +0300
commitcc0b05a4cc54c30a5355a9da5d76b1879d960628 (patch)
tree35bbd54f2957dec2df68671ee51c0a33eef8fc33 /list-objects-filter-options.c
parent696aa73905c8c11b06735f9db830e55bc369849a (diff)
list-objects-filter-options: do not over-strbuf_init
The function gently_parse_list_objects_filter is either called with errbuf=STRBUF_INIT or errbuf=NULL, but that function calls strbuf_init when errbuf is not NULL. strbuf_init is only necessary if errbuf contains garbage, and risks a memory leak if errbuf already has a non-STRBUF_INIT state. It should be the caller's responsibility to make sure errbuf is not garbage, since garbage content is easily avoidable with STRBUF_INIT. Signed-off-by: Matthew DeVore <matvore@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'list-objects-filter-options.c')
-rw-r--r--list-objects-filter-options.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/list-objects-filter-options.c b/list-objects-filter-options.c
index c0e2bd6a06..d259bdb2c1 100644
--- a/list-objects-filter-options.c
+++ b/list-objects-filter-options.c
@@ -30,7 +30,6 @@ static int gently_parse_list_objects_filter(
if (filter_options->choice) {
if (errbuf) {
- strbuf_init(errbuf, 0);
strbuf_addstr(
errbuf,
_("multiple filter-specs cannot be combined"));
@@ -71,10 +70,9 @@ static int gently_parse_list_objects_filter(
return 0;
}
- if (errbuf) {
- strbuf_init(errbuf, 0);
+ if (errbuf)
strbuf_addf(errbuf, "invalid filter-spec '%s'", arg);
- }
+
memset(filter_options, 0, sizeof(*filter_options));
return 1;
}