summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2011-04-04 16:46:21 +0200
committerStefan Metzmacher <metze@samba.org>2011-04-08 09:28:10 +0200
commitefbb35824e3845c3cdefea328dd1bf67d0f9087d (patch)
tree5b3e11badaaa35cd8fb31c306865b778ef3da9a6
parent1e70439f770181ca16a0749c2164d0237d3bfd0a (diff)
downloadsamba-efbb35824e3845c3cdefea328dd1bf67d0f9087d.tar.gz
samba-efbb35824e3845c3cdefea328dd1bf67d0f9087d.tar.bz2
samba-efbb35824e3845c3cdefea328dd1bf67d0f9087d.zip
talloc: use VALGRIND_MAKE_MEM_UNDEFINED() before memmove()
metze Signed-off-By: Andrew Tridgell <tridge@samba.org>
-rw-r--r--lib/talloc/talloc.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/talloc/talloc.c b/lib/talloc/talloc.c
index 4aa85d068c..8dec01fd41 100644
--- a/lib/talloc/talloc.c
+++ b/lib/talloc/talloc.c
@@ -1321,6 +1321,18 @@ _PUBLIC_ void *_talloc_realloc(const void *context, void *ptr, size_t size, cons
if (space_left >= space_needed) {
size_t old_used = TC_HDR_SIZE + tc->size;
pool_tc->pool = TC_POOL_FIRST_CHUNK(pool_tc);
+#if defined(DEVELOPER) && defined(VALGRIND_MAKE_MEM_UNDEFINED)
+ /*
+ * we need to prepare the memmove into
+ * the unaccessable area.
+ */
+ {
+ size_t diff = PTR_DIFF(tc, pool_tc->pool);
+ size_t flen = MIN(diff, old_used);
+ char *fptr = (char *)pool_tc->pool;
+ VALGRIND_MAKE_MEM_UNDEFINED(fptr, flen);
+ }
+#endif
memmove(pool_tc->pool, tc, old_used);
new_ptr = pool_tc->pool;