summaryrefslogtreecommitdiff
path: root/builtin/submodule--helper.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2021-08-04 13:28:52 -0700
committerLibravatar Junio C Hamano <gitster@pobox.com>2021-08-04 13:28:52 -0700
commit31f9acf9ce29ae210b54997f7fb388a2dc543d53 (patch)
treeec42e72471831dd47a31bd467e32b4bce6499be7 /builtin/submodule--helper.c
parentMerge branch 'ar/submodule-add' (diff)
parentreset: clear_unpack_trees_porcelain to plug leak (diff)
downloadtgif-31f9acf9ce29ae210b54997f7fb388a2dc543d53.tar.xz
Merge branch 'ah/plugleaks'
Leak plugging. * ah/plugleaks: reset: clear_unpack_trees_porcelain to plug leak builtin/rebase: fix options.strategy memory lifecycle builtin/merge: free found_ref when done builtin/mv: free or UNLEAK multiple pointers at end of cmd_mv convert: release strbuf to avoid leak read-cache: call diff_setup_done to avoid leak ref-filter: also free head for ATOM_HEAD to avoid leak diffcore-rename: move old_dir/new_dir definition to plug leak builtin/for-each-repo: remove unnecessary argv copy to plug leak builtin/submodule--helper: release unused strbuf to avoid leak environment: move strbuf into block to plug leak fmt-merge-msg: free newly allocated temporary strings when done
Diffstat (limited to 'builtin/submodule--helper.c')
-rw-r--r--builtin/submodule--helper.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 53d23796f2..ef2776a9e4 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -187,11 +187,13 @@ static char *relative_url(const char *remote_url,
out = xstrdup(sb.buf + 2);
else
out = xstrdup(sb.buf);
- strbuf_reset(&sb);
- if (!up_path || !is_relative)
+ if (!up_path || !is_relative) {
+ strbuf_release(&sb);
return out;
+ }
+ strbuf_reset(&sb);
strbuf_addf(&sb, "%s%s", up_path, out);
free(out);
return strbuf_detach(&sb, NULL);