Skip to content

Commit

Permalink
fixup! maintenance: care about gvfs.sharedCache config
Browse files Browse the repository at this point in the history
The bug here is that object_dir was being set to an internal pointer
within git_config_get_value(), but then getting clobbered by the stack
or something. The xstrdup() here ensures that we don't lose the value
this way.

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
  • Loading branch information
derrickstolee committed Nov 16, 2021
1 parent bbceaa8 commit 70c619f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions builtin/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1433,6 +1433,7 @@ static int maintenance_run(int argc, const char **argv, const char *prefix)
{
int i;
struct maintenance_run_opts opts;
const char *tmp_obj_dir = NULL;
struct option builtin_maintenance_run_options[] = {
OPT_BOOL(0, "auto", &opts.auto_flag,
N_("run tasks based on the state of the repository")),
Expand Down Expand Up @@ -1472,9 +1473,11 @@ static int maintenance_run(int argc, const char **argv, const char *prefix)
* the gvfs.sharedcache config option to redirect the
* maintenance to that location.
*/
if (!git_config_get_value("gvfs.sharedcache", &object_dir) &&
object_dir)
if (!git_config_get_value("gvfs.sharedcache", &tmp_obj_dir) &&
tmp_obj_dir) {
object_dir = xstrdup(tmp_obj_dir);
setenv(DB_ENVIRONMENT, object_dir, 1);
}

return maintenance_run_tasks(&opts);
}
Expand Down

0 comments on commit 70c619f

Please sign in to comment.