Merge branch 'jc/clone-remote-name-leak-fix'

"git clone --origin X" leaked piece of memory that held value read
from the clone.defaultRemoteName configuration variable, which has
been plugged.

* jc/clone-remote-name-leak-fix:
  clone: plug a miniscule leak
maint
Junio C Hamano 2022-05-04 09:51:28 -07:00
commit 8ed16bd600
1 changed files with 3 additions and 1 deletions

View File

@ -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 * apply the remote name provided by --origin only after this second
* call to git_config, to ensure it overrides all config-based values. * 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); remote_name = xstrdup(option_origin);
}


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