Skip to content

Commit 6dfadc8

Browse files
committed
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 <[email protected]>
1 parent 6cd33dc commit 6dfadc8

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

builtin/clone.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1106,8 +1106,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
11061106
* apply the remote name provided by --origin only after this second
11071107
* call to git_config, to ensure it overrides all config-based values.
11081108
*/
1109-
if (option_origin != NULL)
1109+
if (option_origin != NULL) {
1110+
free(remote_name);
11101111
remote_name = xstrdup(option_origin);
1112+
}
11111113

11121114
if (remote_name == NULL)
11131115
remote_name = xstrdup("origin");

0 commit comments

Comments
 (0)