From eff3fd32618646a3777c4507b8d7fdf4aca2ba8c Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Tue, 16 Jun 2015 17:37:15 -1000 Subject: [PATCH] git save: fix crash with no remote Commit e21cae2d46db ("Cloud storage: sync the remote after save") broke regular git saving without any remotes: it would never initialize the "remote" pointer, and then use that uninitialized remote pointer to see if it was a cloud storage remote that it should try to sync. Fix it. Signed-off-by: Linus Torvalds Signed-off-by: Dirk Hohndel --- git-access.c | 2 ++ save-git.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/git-access.c b/git-access.c index 2d914ebfe..3a99d591c 100644 --- a/git-access.c +++ b/git-access.c @@ -568,6 +568,8 @@ struct git_repository *is_git_repository(const char *filename, const char **bran free(branch); return dummy_git_repository; } + if (remote) + *remote = NULL; *branchp = branch; return repo; } diff --git a/save-git.c b/save-git.c index 6e44b0851..64e04823b 100644 --- a/save-git.c +++ b/save-git.c @@ -1139,7 +1139,7 @@ int do_git_save(git_repository *repo, const char *branch, const char *remote, bo if (create_new_commit(repo, branch, &id)) return report_error("creating commit failed"); - if (prefs.cloud_background_sync) { + if (remote && prefs.cloud_background_sync) { /* now sync the tree with the cloud server */ if (strstr(remote, prefs.cloud_git_url)) { return sync_with_remote(repo, remote, branch, RT_HTTPS);