Fix 2 bugs in online::push tests. - Fix stack corruption introduced in 9bccf33c due to passing pointer to local variable _cred_acquire_called. - Fix strcmp in do_verify_push_status when expected or actual push_status is NULL
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
diff --git a/tests-clar/online/push.c b/tests-clar/online/push.c
index 3e2e334..8f92cdd 100644
--- a/tests-clar/online/push.c
+++ b/tests-clar/online/push.c
@@ -14,6 +14,7 @@ static char *_remote_user;
static char *_remote_pass;
static git_remote *_remote;
+static bool _cred_acquire_called;
static record_callbacks_data _record_cbs_data = {{ 0 }};
static git_remote_callbacks _record_cbs = RECORD_CALLBACKS_INIT(&_record_cbs_data);
@@ -79,7 +80,9 @@ static void do_verify_push_status(git_push *push, const push_status expected[],
else
git_vector_foreach(&actual, i, iter)
if (strcmp(expected[i].ref, iter->ref) ||
- (expected[i].msg && strcmp(expected[i].msg, iter->msg))) {
+ (expected[i].msg && !iter->msg) ||
+ (!expected[i].msg && iter->msg) ||
+ (expected[i].msg && iter->msg && strcmp(expected[i].msg, iter->msg))) {
failed = true;
break;
}
@@ -231,7 +234,7 @@ void test_online_push__initialize(void)
git_vector delete_specs = GIT_VECTOR_INIT;
size_t i;
char *curr_del_spec;
- bool cred_acquire_called = false;
+ _cred_acquire_called = false;
_repo = cl_git_sandbox_init("push_src");
@@ -272,7 +275,7 @@ void test_online_push__initialize(void)
if (_remote_url) {
cl_git_pass(git_remote_create(&_remote, _repo, "test", _remote_url));
- git_remote_set_cred_acquire_cb(_remote, cred_acquire_cb, &cred_acquire_called);
+ git_remote_set_cred_acquire_cb(_remote, cred_acquire_cb, &_cred_acquire_called);
record_callbacks_data_clear(&_record_cbs_data);
git_remote_set_callbacks(_remote, &_record_cbs);