]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'ps/leakfixes'
authorJunio C Hamano <gitster@pobox.com>
Thu, 6 Jun 2024 19:49:23 +0000 (12:49 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 6 Jun 2024 19:49:23 +0000 (12:49 -0700)
Leakfixes.

* ps/leakfixes:
  builtin/mv: fix leaks for submodule gitfile paths
  builtin/mv: refactor to use `struct strvec`
  builtin/mv duplicate string list memory
  builtin/mv: refactor `add_slash()` to always return allocated strings
  strvec: add functions to replace and remove strings
  submodule: fix leaking memory for submodule entries
  commit-reach: fix memory leak in `ahead_behind()`
  builtin/credential: clear credential before exit
  config: plug various memory leaks
  config: clarify memory ownership in `git_config_string()`
  builtin/log: stop using globals for format config
  builtin/log: stop using globals for log config
  convert: refactor code to clarify ownership of check_roundtrip_encoding
  diff: refactor code to clarify memory ownership of prefixes
  config: clarify memory ownership in `git_config_pathname()`
  http: refactor code to clarify memory ownership
  checkout: clarify memory ownership in `unique_tracking_name()`
  strbuf: fix leak when `appendwholeline()` fails with EOF
  transport-helper: fix leaking helper name

16 files changed:
1  2 
Makefile
attr.c
builtin/blame.c
builtin/config.c
builtin/log.c
builtin/repack.c
builtin/worktree.c
config.c
config.h
fetch-pack.c
fsck.c
remote.c
sequencer.c
setup.c
t/t1350-config-hooks-path.sh
upload-pack.c

diff --cc Makefile
index 59d98ba688f1780d9d49be0aced214c9c6ab58fd,d4000fb1d69bcc47dbe1a2f820860ec138f03324..2f5f16847ae28eb1080e0544a54fada066f31a07
+++ b/Makefile
@@@ -1333,12 -1334,11 +1333,13 @@@ THIRD_PARTY_SOURCES += compat/regex/
  THIRD_PARTY_SOURCES += sha1collisiondetection/%
  THIRD_PARTY_SOURCES += sha1dc/%
  
 +UNIT_TEST_PROGRAMS += t-ctype
  UNIT_TEST_PROGRAMS += t-mem-pool
 +UNIT_TEST_PROGRAMS += t-prio-queue
  UNIT_TEST_PROGRAMS += t-strbuf
 -UNIT_TEST_PROGRAMS += t-ctype
 -UNIT_TEST_PROGRAMS += t-prio-queue
 +UNIT_TEST_PROGRAMS += t-strcmp-offset
+ UNIT_TEST_PROGRAMS += t-strvec
 +UNIT_TEST_PROGRAMS += t-trailer
  UNIT_TEST_PROGS = $(patsubst %,$(UNIT_TEST_BIN)/%$X,$(UNIT_TEST_PROGRAMS))
  UNIT_TEST_OBJS = $(patsubst %,$(UNIT_TEST_DIR)/%.o,$(UNIT_TEST_PROGRAMS))
  UNIT_TEST_OBJS += $(UNIT_TEST_DIR)/test-lib.o
diff --cc attr.c
Simple merge
diff --cc builtin/blame.c
Simple merge
index c38264c999a2e6468027fa40627564500e54d494,cc343f55cac8e8bed5e78fede64036b342c44aa7..20a0b64090eab56d3b6a54073e338fdbf5db4448
@@@ -288,8 -276,8 +288,8 @@@ static int format_config(const struct c
                                strbuf_addstr(buf, value_);
                        else
                                strbuf_addstr(buf, v ? "true" : "false");
 -              } else if (type == TYPE_PATH) {
 +              } else if (opts->type == TYPE_PATH) {
-                       const char *v;
+                       char *v;
                        if (git_config_pathname(&v, key_, value_) < 0)
                                return -1;
                        strbuf_addstr(buf, v);
diff --cc builtin/log.c
Simple merge
Simple merge
Simple merge
diff --cc config.c
index 14461312b336dce8761334fe819c320cc9e5436d,496cd1a61eaa0aec346caa1c01d1bfc56155472b..abce05b7744a91477a6d11c43501e02e6bf4c734
+++ b/config.c
@@@ -1414,11 -1414,25 +1414,15 @@@ static int git_default_core_config(cons
                return 0;
        }
  
-       if (!strcmp(var, "core.attributesfile"))
+       if (!strcmp(var, "core.attributesfile")) {
+               FREE_AND_NULL(git_attributes_file);
                return git_config_pathname(&git_attributes_file, var, value);
+       }
  
-       if (!strcmp(var, "core.hookspath"))
+       if (!strcmp(var, "core.hookspath")) {
 -              if (ctx->kvi && ctx->kvi->scope == CONFIG_SCOPE_LOCAL &&
 -                  git_env_bool("GIT_CLONE_PROTECTION_ACTIVE", 0))
 -                      die(_("active `core.hooksPath` found in the local "
 -                            "repository config:\n\t%s\nFor security "
 -                            "reasons, this is disallowed by default.\nIf "
 -                            "this is intentional and the hook should "
 -                            "actually be run, please\nrun the command "
 -                            "again with "
 -                            "`GIT_CLONE_PROTECTION_ACTIVE=false`"),
 -                          value);
+               FREE_AND_NULL(git_hooks_path);
                return git_config_pathname(&git_hooks_path, var, value);
+       }
  
        if (!strcmp(var, "core.bare")) {
                is_bare_repository_cfg = git_config_bool(var, value);
diff --cc config.h
Simple merge
diff --cc fetch-pack.c
Simple merge
diff --cc fsck.c
Simple merge
diff --cc remote.c
Simple merge
diff --cc sequencer.c
Simple merge
diff --cc setup.c
Simple merge
Simple merge
diff --cc upload-pack.c
Simple merge