From: Junio C Hamano Date: Thu, 6 Jun 2024 19:49:23 +0000 (-0700) Subject: Merge branch 'ps/leakfixes' X-Git-Tag: v2.46.0-rc0~76 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cf792653ad407badec34e67612231676057f9532;p=thirdparty%2Fgit.git Merge branch 'ps/leakfixes' 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 --- cf792653ad407badec34e67612231676057f9532 diff --cc Makefile index 59d98ba688,d4000fb1d6..2f5f16847a --- a/Makefile +++ 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-strcmp-offset + UNIT_TEST_PROGRAMS += t-strvec -UNIT_TEST_PROGRAMS += t-ctype -UNIT_TEST_PROGRAMS += t-prio-queue +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 builtin/config.c index c38264c999,cc343f55ca..20a0b64090 --- a/builtin/config.c +++ b/builtin/config.c @@@ -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 config.c index 14461312b3,496cd1a61e..abce05b774 --- a/config.c +++ 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);