crashes.c 628 Bytes
Newer Older
1
#include "clar_libgit2.h"
Vicent Martí committed
2 3 4 5 6 7 8 9

void test_refs_crashes__double_free(void)
{
	git_repository *repo;
	git_reference *ref, *ref2;
	const char *REFNAME = "refs/heads/xxx";

	cl_git_pass(git_repository_open(&repo, cl_fixture("testrepo.git")));
10
	cl_git_pass(git_reference_symbolic_create(&ref, repo, REFNAME, "refs/heads/master", 0));
Vicent Martí committed
11 12
	cl_git_pass(git_reference_lookup(&ref2, repo, REFNAME));
	cl_git_pass(git_reference_delete(ref));
13 14 15
	git_reference_free(ref);
	git_reference_free(ref2);

Vicent Martí committed
16
	/* reference is gone from disk, so reloading it will fail */
17
	cl_git_fail(git_reference_lookup(&ref2, repo, REFNAME));
18 19

	git_repository_free(repo);
Vicent Martí committed
20
}