Fix a few leaks The interesting one is the notification macro, which was returning directly on a soft-abort instead of going through the cleanup.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
diff --git a/src/stash.c b/src/stash.c
index c79068e..0c5cd1d 100644
--- a/src/stash.c
+++ b/src/stash.c
@@ -701,10 +701,14 @@ int git_stash_apply_init_options(git_stash_apply_options *opts, unsigned int ver
return 0;
}
-#define NOTIFY_PROGRESS(opts, progress_type) \
- if ((opts).progress_cb && \
- (error = (opts).progress_cb((progress_type), (opts).progress_payload))) \
- return (error < 0) ? error : -1;
+#define NOTIFY_PROGRESS(opts, progress_type) \
+ do { \
+ if ((opts).progress_cb && \
+ (error = (opts).progress_cb((progress_type), (opts).progress_payload))) { \
+ error = (error < 0) ? error : -1; \
+ goto cleanup; \
+ } \
+ } while(false);
int git_stash_apply(
git_repository *repo,
diff --git a/tests/stash/apply.c b/tests/stash/apply.c
index 213945e..42186b6 100644
--- a/tests/stash/apply.c
+++ b/tests/stash/apply.c
@@ -44,6 +44,8 @@ void test_stash_apply__initialize(void)
assert_status(repo, "how", GIT_STATUS_CURRENT);
assert_status(repo, "who", GIT_STATUS_CURRENT);
assert_status(repo, "when", GIT_ENOTFOUND);
+
+ git_index_free(repo_index);
}
void test_stash_apply__cleanup(void)
diff --git a/tests/submodule/modify.c b/tests/submodule/modify.c
index 1ede56e..bbbb2d5 100644
--- a/tests/submodule/modify.c
+++ b/tests/submodule/modify.c
@@ -257,4 +257,5 @@ void test_submodule_modify__save_last(void)
cl_git_pass(git_submodule_lookup(&sm, g_repo, "sm_gitmodules_only"));
cl_git_pass(git_submodule_save(sm));
+ git_submodule_free(sm);
}