]> git.ozlabs.org Git - ccan/blob - ccan/talloc/test/run-corruption1.c
tdb2: try to fit transactions in existing space before we expand.
[ccan] / ccan / talloc / test / run-corruption1.c
1 /* failtest with valgrind caught this read-after-free. */
2 #include <ccan/talloc/talloc.c>
3 #include <stdbool.h>
4 #include <ccan/tap/tap.h>
5
6 int main(int argc, char *argv[])
7 {
8         void *root, *p1;
9
10         plan_tests(2);
11         talloc_enable_null_tracking();
12         root = talloc_new(NULL);
13         p1 = talloc_strdup(root, "foo");
14         talloc_increase_ref_count(p1);
15         talloc_free(root);
16         ok1(strcmp(p1, "foo") == 0);
17         talloc_unlink(NULL, p1);
18
19         /* This closes the leak, but make sure we're not freeing unexpected. */
20         ok1(!talloc_chunk_from_ptr(null_context)->child);
21         talloc_disable_null_tracking();
22
23         return exit_status();
24 }