summaryrefslogtreecommitdiff
path: root/source3/lib/debug.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2008-08-12 13:35:15 -0700
committerJeremy Allison <jra@samba.org>2008-08-12 13:35:15 -0700
commit03991ab0734ecbb87a75238d1356fbe0e5b1d38d (patch)
treec96c68c0f2fd8359c2250621f4b0938903ae385f /source3/lib/debug.c
parent9caabc441b3bfe860f9719cf64b6646f58a5cb59 (diff)
downloadsamba-03991ab0734ecbb87a75238d1356fbe0e5b1d38d.tar.gz
samba-03991ab0734ecbb87a75238d1356fbe0e5b1d38d.tar.bz2
samba-03991ab0734ecbb87a75238d1356fbe0e5b1d38d.zip
Fix bug 5686 - libsmbclient segfaults with more than one SMBCCTX.
Here is a patch to allow many subsystems to be re-initialized. The only functional change I made was to remove the null context tracking, as the memory allocated here is designed to be left for the complete lifetime of the program. Freeing this early (when all smb contexts are destroyed) could crash other users of talloc. Jeremy. (This used to be commit 8c630efd25cf17aff59448ca05c1b44a41964b16)
Diffstat (limited to 'source3/lib/debug.c')
-rw-r--r--source3/lib/debug.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/source3/lib/debug.c b/source3/lib/debug.c
index 2ded6bdc33..d835ea7c17 100644
--- a/source3/lib/debug.c
+++ b/source3/lib/debug.c
@@ -94,7 +94,7 @@ static TALLOC_CTX *tmp_debug_ctx;
/*
* This is to allow assignment to DEBUGLEVEL before the debug
- * system has been initialised.
+ * system has been initialized.
*/
static int debug_all_class_hack = 1;
static bool debug_all_class_isset_hack = True;
@@ -183,6 +183,8 @@ static char **classname_table = NULL;
Free memory pointed to by global pointers.
****************************************************************************/
+static bool initialized;
+
void gfree_debugsyms(void)
{
int i;
@@ -194,13 +196,23 @@ void gfree_debugsyms(void)
SAFE_FREE( classname_table );
}
- if ( DEBUGLEVEL_CLASS != &debug_all_class_hack )
+ if ( DEBUGLEVEL_CLASS != &debug_all_class_hack ) {
SAFE_FREE( DEBUGLEVEL_CLASS );
+ DEBUGLEVEL_CLASS = &debug_all_class_hack;
+ }
- if ( DEBUGLEVEL_CLASS_ISSET != &debug_all_class_isset_hack )
+ if ( DEBUGLEVEL_CLASS_ISSET != &debug_all_class_isset_hack ) {
SAFE_FREE( DEBUGLEVEL_CLASS_ISSET );
+ DEBUGLEVEL_CLASS_ISSET = &debug_all_class_isset_hack;
+ }
SAFE_FREE(format_bufr);
+
+ debug_num_classes = 0;
+
+ debug_level = DEBUGLEVEL_CLASS;
+
+ initialized = false;
}
/****************************************************************************
@@ -530,13 +542,12 @@ Init debugging (one time stuff)
void debug_init(void)
{
- static bool initialised = False;
const char **p;
- if (initialised)
+ if (initialized)
return;
- initialised = True;
+ initialized = true;
for(p = default_classname_table; *p; p++) {
debug_add_class(*p);