diff options
author | Michael Adam <obnox@samba.org> | 2011-10-28 00:05:44 +0200 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2011-10-28 01:00:01 +0200 |
commit | daf7193c1d04f9a40c26a609e9bacad7f61d63b5 (patch) | |
tree | 235fe6b1c91ae07ffdba2559b26ab691e763c4f1 /source4/torture/smb2 | |
parent | 52b87f63e2f98533c72aef264e066b703e9f0032 (diff) | |
download | samba-daf7193c1d04f9a40c26a609e9bacad7f61d63b5.tar.gz samba-daf7193c1d04f9a40c26a609e9bacad7f61d63b5.tar.bz2 samba-daf7193c1d04f9a40c26a609e9bacad7f61d63b5.zip |
s4:torture:smb2: fix a nasty double free error.
This error manifested itself in sporadic "talloc_free with references" error.
Diffstat (limited to 'source4/torture/smb2')
-rw-r--r-- | source4/torture/smb2/smb2.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/source4/torture/smb2/smb2.c b/source4/torture/smb2/smb2.c index 35a987e927..3bbad29d6b 100644 --- a/source4/torture/smb2/smb2.c +++ b/source4/torture/smb2/smb2.c @@ -30,17 +30,25 @@ static bool wrap_simple_1smb2_test(struct torture_context *torture_ctx, { bool (*fn) (struct torture_context *, struct smb2_tree *); bool ret; - struct smb2_tree *tree1; + TALLOC_CTX *mem_ctx = talloc_new(torture_ctx); if (!torture_smb2_connection(torture_ctx, &tree1)) return false; + /* + * This is a trick: + * The test might close the connection. If we steal the tree context + * before that and free the parent instead of tree directly, we avoid + * a double free error. + */ + talloc_steal(mem_ctx, tree1); + fn = test->fn; ret = fn(torture_ctx, tree1); - talloc_free(tree1); + talloc_free(mem_ctx); return ret; } |