diff options
author | Andrew Tridgell <tridge@samba.org> | 2005-07-01 01:25:55 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:19:00 -0500 |
commit | 9cfe2d83f1103f83ace2ead46e31d7368a29f3c0 (patch) | |
tree | 2d6f7dc7cfc0813a4de7365737daa22947bc47f7 /source4/lib/talloc/testsuite.c | |
parent | 7134b64292a9e124d1280e61ef29810ac7e8c0b0 (diff) | |
download | samba-9cfe2d83f1103f83ace2ead46e31d7368a29f3c0.tar.gz samba-9cfe2d83f1103f83ace2ead46e31d7368a29f3c0.tar.bz2 samba-9cfe2d83f1103f83ace2ead46e31d7368a29f3c0.zip |
r8032: added loop detection into talloc. Robert Collins found a way to make a
memory loop with talloc_unlink(), so now we detect it and handle it
(This used to be commit 563058e78b8c74e821fabf6a43fa861c1ad09944)
Diffstat (limited to 'source4/lib/talloc/testsuite.c')
-rw-r--r-- | source4/lib/talloc/testsuite.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/source4/lib/talloc/testsuite.c b/source4/lib/talloc/testsuite.c index 60da1c3f87..422cb8fee5 100644 --- a/source4/lib/talloc/testsuite.c +++ b/source4/lib/talloc/testsuite.c @@ -818,6 +818,26 @@ static BOOL test_speed(void) } +BOOL test_lifeless(void) +{ + char *top = talloc_new(NULL); + char *parent, *child; + char *child_owner = talloc_new(NULL); + + printf("TESTING TALLOC_UNLINK LOOP\n"); + + parent = talloc_strdup(top, "parent"); + child = talloc_strdup(parent, "child"); + talloc_reference(child, parent); + talloc_reference(child_owner, child); + talloc_unlink(top, parent); + talloc_free(child); + talloc_report_full(top, stdout); + talloc_free(top); + return True; +} + + BOOL torture_local_talloc(void) { BOOL ret = True; @@ -834,6 +854,7 @@ BOOL torture_local_talloc(void) ret &= test_unref_reparent(); ret &= test_realloc_fn(); ret &= test_type(); + ret &= test_lifeless(); if (ret) { ret &= test_speed(); } |