svn commit: samba r1991 - branches/SAMBA_4_0/source/lib
abartlet at samba.org
abartlet at samba.org
Sun Aug 22 05:35:43 GMT 2004
Author: abartlet
Date: 2004-08-22 05:35:43 +0000 (Sun, 22 Aug 2004)
New Revision: 1991
WebSVN: http://websvn.samba.org/websvn/changeset.php?rep=samba&path=/&rev=1991&nolog=1
Log:
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
Modified:
branches/SAMBA_4_0/source/lib/talloc.c
Changeset:
Modified: branches/SAMBA_4_0/source/lib/talloc.c
===================================================================
--- branches/SAMBA_4_0/source/lib/talloc.c 2004-08-22 05:33:07 UTC (rev 1990)
+++ branches/SAMBA_4_0/source/lib/talloc.c 2004-08-22 05:35:43 UTC (rev 1991)
@@ -66,6 +66,7 @@
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 @@
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 @@
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 @@
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;
}
More information about the samba-cvs
mailing list