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:
authorJunio C Hamano <gitster@pobox.com>2022-05-01 08:17:15 +0300
committerJunio C Hamano <gitster@pobox.com>2022-05-01 08:22:12 +0300
commit6dfadc8981a3f2fd3fb552eb956fe12a542f8ee8 (patch)
tree6ceb2453d4662d4234cc7049ca2c786c4349e629
parent6cd33dceed60949e2dbc32e3f0f5e67c4c882e1e (diff)
clone: plug a miniscule leak
The remote_name variable is first assigned a copy of the value of the "clone.defaultremotename" configuration variable and then by the value of the "--origin" command line option. The former is prepared to see multiple instances of the configuration variable by freeing the current value of the variable before a copy of the newly discovered value gets assigned to it. The latter however blindly assigned a copy of the new value to the variable, thereby leaking the value read from the configuration variable. Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--builtin/clone.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/builtin/clone.c b/builtin/clone.c
index 5231656379..194d50f75f 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -1106,8 +1106,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
* apply the remote name provided by --origin only after this second
* call to git_config, to ensure it overrides all config-based values.
*/
- if (option_origin != NULL)
+ if (option_origin != NULL) {
+ free(remote_name);
remote_name = xstrdup(option_origin);
+ }
if (remote_name == NULL)
remote_name = xstrdup("origin");