summaryrefslogtreecommitdiff
path: root/source4/lib
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2004-08-22 05:35:43 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:58:15 -0500
commit39a3d5eedc04a365cf2df215a39bec4fc8e170f0 (patch)
tree34646a5c4cf7cd4c476df6536b9b9851ca94405b /source4/lib
parentdcd43a4cbef3bee948bdbd65212361b6043aa4bd (diff)
downloadsamba-39a3d5eedc04a365cf2df215a39bec4fc8e170f0.tar.gz
samba-39a3d5eedc04a365cf2df215a39bec4fc8e170f0.tar.bz2
samba-39a3d5eedc04a365cf2df215a39bec4fc8e170f0.zip
r1991: After finding a talloc inconsistancy is a very good time to smb_panic(),
it can only indicate programmer error, and doing a smb_panic() ensures an automatic backtrace (and eventually an abort()). Andrew Bartlett (This used to be commit b2d93d0010d80f158760f53273853de2439c3062)
Diffstat (limited to 'source4/lib')
-rw-r--r--source4/lib/talloc.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/source4/lib/talloc.c b/source4/lib/talloc.c
index b01bcb27c8..4a48347832 100644
--- a/source4/lib/talloc.c
+++ b/source4/lib/talloc.c
@@ -66,6 +66,7 @@ void *talloc(void *context, size_t size)
if (parent->magic != TALLOC_MAGIC) {
DEBUG(0,("Bad magic in context - 0x%08x\n", parent->magic));
free(tc);
+ smb_panic("Bad magic in talloc context");
return NULL;
}
@@ -172,6 +173,7 @@ void talloc_free(void *ptr)
if (tc->magic != TALLOC_MAGIC) {
DEBUG(0,("Bad talloc magic 0x%08x in talloc_free\n", tc->magic));
+ smb_panic("Bad talloc magic in talloc_realloc");
return;
}
@@ -219,8 +221,14 @@ void *talloc_realloc(void *ptr, size_t size)
tc = ((struct talloc_chunk *)ptr)-1;
if (tc->magic != TALLOC_MAGIC) {
- DEBUG(0,("Bad talloc magic 0x%08x in talloc_realloc\n", tc->magic));
- return NULL;
+ if (tc->magic == TALLOC_MAGIC_FREE) {
+
+ DEBUG(0,("Bad talloc magic - magic 0x%08x indicates double-free in talloc_realloc\n", tc->magic));
+ smb_panic("Bad talloc magic - double-free - in talloc_realloc");
+ } else {
+ DEBUG(0,("Bad talloc magic 0x%08x in talloc_realloc\n", tc->magic));
+ smb_panic("Bad talloc magic in talloc_realloc");
+ }
}
/* by resetting magic we catch users of the old memory */
@@ -267,10 +275,12 @@ void *talloc_steal(void *new_ctx, void *ptr)
if (tc->magic != TALLOC_MAGIC) {
DEBUG(0,("Bad talloc magic 0x%08x in talloc_steal\n", tc->magic));
+ smb_panic("Bad talloc magic in talloc_steal");
return NULL;
}
if (new_tc->magic != TALLOC_MAGIC) {
DEBUG(0,("Bad new talloc magic 0x%08x in talloc_steal\n", new_tc->magic));
+ smb_panic("Bad new talloc magic in talloc_steal");
return NULL;
}