summaryrefslogtreecommitdiffstats
path: root/source/torture
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2008-11-13 23:50:19 +0100
committerKarolin Seeger <kseeger@samba.org>2008-12-09 11:39:08 +0100
commit22e928fec2cf2ec26b7eb0e2bb3851519760c876 (patch)
tree829a811d4bfbd1637365df2e45ba718ca7999029 /source/torture
parent72f883cea0b4b69f639d30d79aceef34f0ec4fe4 (diff)
downloadsamba-22e928fec2cf2ec26b7eb0e2bb3851519760c876.tar.gz
samba-22e928fec2cf2ec26b7eb0e2bb3851519760c876.tar.xz
samba-22e928fec2cf2ec26b7eb0e2bb3851519760c876.zip
Actually finish memcache_add_talloc
This fixes a memleak found by Martin Zielinski <mz@seh.de>. Thanks for looking closely! Volker (cherry picked from commit 26b1fda4020b7f6629865ae1c62e9b464222e1a2)
Diffstat (limited to 'source/torture')
-rw-r--r--source/torture/torture.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/source/torture/torture.c b/source/torture/torture.c
index e909f8cec81..8419be76a50 100644
--- a/source/torture/torture.c
+++ b/source/torture/torture.c
@@ -5188,6 +5188,11 @@ static bool run_local_memcache(int dummy)
DATA_BLOB d1, d2, d3;
DATA_BLOB v1, v2, v3;
+ TALLOC_CTX *mem_ctx;
+ char *str1, *str2;
+ size_t size1, size2;
+ bool ret = false;
+
cache = memcache_init(NULL, 100);
if (cache == NULL) {
@@ -5239,7 +5244,33 @@ static bool run_local_memcache(int dummy)
}
TALLOC_FREE(cache);
- return true;
+
+ cache = memcache_init(NULL, 0);
+
+ mem_ctx = talloc_init("foo");
+
+ str1 = talloc_strdup(mem_ctx, "string1");
+ str2 = talloc_strdup(mem_ctx, "string2");
+
+ memcache_add_talloc(cache, SINGLETON_CACHE_TALLOC,
+ data_blob_string_const("torture"), str1);
+ size1 = talloc_total_size(cache);
+
+ memcache_add_talloc(cache, SINGLETON_CACHE_TALLOC,
+ data_blob_string_const("torture"), str2);
+ size2 = talloc_total_size(cache);
+
+ printf("size1=%d, size2=%d\n", (int)size1, (int)size2);
+
+ if (size2 > size1) {
+ printf("memcache leaks memory!\n");
+ goto fail;
+ }
+
+ ret = true;
+ fail:
+ TALLOC_FREE(cache);
+ return ret;
}
static double create_procs(bool (*fn)(int), bool *result)